Package: django-newsletter-signup
A reusable Django app, that handles newsletter subscriptions.Important note!If you upgrade from 0.2 upwards, you need to be aware, that the migrations were
reset. They used to be south, but they have been re-created to new Django
migrations in 0.3.If you’re first install is on 0.3 or beyond, you don’t have to do anything.InstallationTo get the latest stable release from PyPipipinstalldjango-newsletter-signupTo get the latest commit from GitHubpipinstall-egit+git://github.com/bitmazk/django-newsletter-signup.git#egg=newsletter_signupAddnewsletter_signupto yourINSTALLED_APPSINSTALLED_APPS=(...,'newsletter_signup',)Add thenewsletter_signupURLs to yoururls.pyurlpatterns=patterns('',...url(r'^newsletter/',include('newsletter_signup.urls')),)Add the provided middleware to catch all referrersMIDDLEWARE_CLASSES=('...',# your other middlewares'newsletter.middleware.GetRefererMiddleware',)Don’t forget to migrate your database./manage.pymigratenewsletter_signupUsageJust link to the signup page or fetch it’s contents via AJAX into e.g. a
bootstrap modal. Once a user fills out the subscription form she gets a
verification email, that on click makes the Subscription verified.Future updates might include mailchimp integration to have everything setup
right away. For now you then need to gather the emails from the admin or your
own custom management views that you want to send mails to, or alternatively
create a custom management command.Management Commandscheck_newsletter_signupsThis command will iterate through all signups and check if there’s a user in
the system matching a signup’s email. You might want to run this command in a
cron job.SettingsDOMAINDefault = 'locahost:8000'DOMAINis the hostname of your site.DOMAIN='example.com'NEWSLETTER_SIGNUP_FROM_EMAILTo set the from email in the mails, you can either specifically set theNEWSLETTER_SIGNUP_FROM_EMAILsetting or only theFROM_EMAILsetting,
which it per default falls back to...code-block:: pythonNEWSLETTER_SIGNUP_FROM_EMAIL =‘news@example.com’NEWSLETTER_SIGNUP_SUBSCRIBE_SUBJECT and NEWSLETTER_SIGNUP_UNSUBSCRIBE_SUBJECTBoth of these setting work in the same way as they set the email subject for
the subscripe and unsubscribe email. You can either provide a string or a
callable object receiving the subscription object as a parameter.
Seemodels.pyfor details. Alternatively you could overwrite those two
templatesemail/unsubscripe_subject.htmlandemail/subscripe_subject.html...code-block:: pythonSUBSCRIBE_SUBJECT = ‘Your subscription to our newsletter!’UNSUBSCRIBE_SUBJECT = lambda sub: ‘{0} was unsubscribed.’.format(sub.email)NEWSLETTER_SIGNUP_FORCE_MODALDefault = FalseIf you use a modal or some other kind of visual element, to hint at the
newsletter, you can set this to True to always show it.It’s intended, that you do something like this in your template:{% if not request.session.has_seen_newsletter_signup_modal %}
    {% has_seen_modal %}
    {% include "path/to/newsletter_signup_modal.html" %}
{% endif %}Thehas_seen_modaltemplate tag sets the session valuehas_seen_newsletter_signup_modaltoTruewhen the tag is rendered.That way, the user won’t see the modal the next time the view is called, unless
you setNEWSLETTER_SIGNUP_FORCE_MODALtoTrue, since that prevents the
session value from becomingTruein the first place.NEWSLETTER_SIGNUP_NAME_REQUIREDDefault = FalseIf set toTruethis setting will addfirst_nameandlast_namefields
to the signup form. These values are then stored on theNewsletterSignupmodel.NEWSLETTER_SIGNUP_VERIFICATION_REQUIREDDefault = FalseIf set toTruethe user will receive an email after signing up with a
verification link.
Same goes for unsubscription.
Per default the user is just (un)subscribed on form submit.ContributeIf you want to contribute to this project, please perform the following steps# Fork this repository
# Clone your forkmkvirtualenv-ppython2.7django-newsletter-signupmakedevelopgitco-bfeature_branchmaster# Implement your feature and testsgitadd.&&gitcommitgitpush-uoriginfeature_branch# Send us a pull request for your feature branch