Another newsletter subscription app.
- User enters his/her email address on
- A mail is sent to the given address containing a link of the form
- Upon visiting the link the user is immediately subscribed for the newsletter. Optionally, a form asking the user for additional data is shown.
- The user enters his/her email address on
/newsletter/and is immediately unsubscribed.
- An email is sent to the user informing him/her that the unsubscription took
place. A link is provided to immediately subscribe again in case the
unsubscription was not meant to take place. The link is of the form
The minimal set of database fields is as follows:
BooleanField, defaults to
This example assumes you are using at least Django 1.4.
Add a concrete model inheriting
newsletter_subscription.models.SubscriptionBasewith optionally additional fields about the subscription. You should be prepared to work without those additional fields -- their presence is not enforced as per the subscription flow description above. A full example:
from django.db import models from django.utils.translation import ugettext_lazy as _ from newsletter_subscription.models import SubscriptionBase class Subscription(SubscriptionBase): full_name = models.CharField(_('full name'), max_length=100, blank=True)
Add the URLconf entry:
from .newsletter.models import Subscription from newsletter_subscription.backend import ModelBackend from newsletter_subscription.urls import newsletter_subscriptions_urlpatterns urlpatterns += patterns( '', url( r'^newsletter/', include(newsletter_subscriptions_urlpatterns( backend=ModelBackend(Subscription), )), ), )
Register your own subscription model with
INSTALLED_APPSif you want to use the bundled templates. The templates require Towel's
towel_form_tagstemplate tag library.