Skip to main content

Another newsletter subscription app.

Project description

==============================
django-newsletter-subscription
==============================

Another newsletter subscription app.

.. image:: https://travis-ci.org/matthiask/django-newsletter-subscription.png?branch=master
:target: https://travis-ci.org/matthiask/django-newsletter-subscription


Subscription flow
=================

- User enters his/her email address on ``/newsletter/``.
- A mail is sent to the given address containing a link of the form
``/newsletter/s/<signed_email_address>/``.
- Upon visiting the link the user is immediately subscribed for the newsletter.
Optionally, a form asking the user for additional data is shown.


Unsubscription flow
===================

- 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
``/newsletter/r/<signed_email_address>/``.


Subscription model
==================

The minimal set of database fields is as follows:

- ``email`` (``EmailField``, unique)
- ``is_active`` (``BooleanField``, defaults to ``False``)


Usage
=====

This example assumes you are using at least Django 1.4.

1. Install ``django-newsletter-subscription`` using pip.

2. Add a concrete model inheriting
``newsletter_subscription.models.SubscriptionBase`` with 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)

3. 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),
)),
),
)

4. Register your own subscription model with ``django.contrib.admin``.

5. Add ``newsletter_subscription`` to ``INSTALLED_APPS`` if you want to use
the bundled templates. The templates require
`Towel <https://github.com/matthiask/towel/>`_'s ``towel_form_tags``
template tag library.

6. Ensure that Django's
`messages framework <https://docs.djangoproject.com/en/1.9/ref/contrib/messages/>`_
is activated and that the messages are included in your templates, otherwise
``django-newsletter-subscriptions``s notifications will not be shown to the
users.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-newsletter-subscription-0.4.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

django_newsletter_subscription-0.4.0-py2.py3-none-any.whl (15.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-newsletter-subscription-0.4.0.tar.gz.

File metadata

File hashes

Hashes for django-newsletter-subscription-0.4.0.tar.gz
Algorithm Hash digest
SHA256 fb2f586ebeaf18c91340ce47440ea302dbcd70e4e39260572e565ed153a21f50
MD5 1a695087518ea8ef59a0026f7662ff60
BLAKE2b-256 838d35ebf45f088a07e0b6cd7ac758fa480f08f2c9744674520c6882dd8c93e8

See more details on using hashes here.

File details

Details for the file django_newsletter_subscription-0.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_newsletter_subscription-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fb068b2610862d2818138a54db74915db01f19ce9a1801175129a46d9314d3c8
MD5 f80fe95ae2a3540f5294d870f7eb09b4
BLAKE2b-256 6286b50d2b540a6fb148f49496f7bc59096e6989a137795460dd0528e257c8d5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page