django_mailjet Package

django_mailjet Package

Introduction

mailjet.contrib.django_mailjet provides generic tools to plug basic mailjet support in your project.

Advanced users may use mailjet.contrib.django_mailjet.forms.SubscriptionForm directly without installing anything.

Installation

In settings.py:

  • set MAILJET_LIST_NAME and MAILJET_LIST_LABEL, note that it may not contain non-alphanumeric characters, those are used as defaults for mailjet.contrib.django_mailjet.forms.SubscriptionForm,
  • add to INSTALLED_APPS: mailjet.contrib.django_mailjet for templates to be loadable.

Include mailjet.contrib.django_mailjet.urls in urls.py, ie.:

url(r'^newsletter/', include('mailjet.contrib.django_mailjet.urls')),

Users may now subscribe to your mailing list on /newsletter/.

forms Module

class mailjet.contrib.django_mailjet.forms.SubscriptionForm(list_name=None, list_label=None, *args, **kwargs)[source]

Bases: django.forms.forms.Form

Simple subscription form

add_contact()[source]

Create a contact with using the email on the list.

api

Get or create an Api() instance using django settings.

base_fields = OrderedDict([('email', <django.forms.fields.EmailField object>)])
clean_email()[source]

Raise ValidationError if the contact exists.

declared_fields = OrderedDict([('email', <django.forms.fields.EmailField object>)])
list_id

Get or create the list id.

media
save()[source]

Call add_contact()

models Module

tests Module

class mailjet.contrib.django_mailjet.tests.SubscriptionFormTest(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

list_name_and_label()[source]
setUp()[source]
tearDown()[source]
test_add_contact()[source]
test_clean_email()[source]
test_save()[source]
test_settings_override()[source]

urls Module

Defines basic urls.

django_mailjet_subscription_form
Url to the basic form view: SubscriptionView.
django_mailjet_subscription_success
Url to the basic success template.

views Module

class mailjet.contrib.django_mailjet.views.SubscriptionView(**kwargs)[source]

Bases: django.views.generic.edit.FormView

Basic subscription views

form_class

alias of SubscriptionForm

form_valid(form)[source]

Call form.save() and super itself.

success_url = <django.utils.functional.__proxy__ object>
template_name = 'django_mailjet/subscription_form.html'