Installation

  1. Install the package from PyPI:

    pip install django-newsletter
    

    Or get the latest & greatest from Github and link it to your application tree:

    pip install -e git://github.com/dokterbob/django-newsletter.git#egg=django-newsletter
    

    (In either case it is recommended that you use VirtualEnv in order to keep your Python environment somewhat clean.)

  2. Add newsletter to INSTALLED_APPS in settings.py and make sure that your favourite rich text widget (optional), some Django contrib dependencies and sorl-thumbnail are in there as well:

    INSTALLED_APPS = (
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.auth',
        'django.contrib.sites',
        ...
        # Imperavi (or tinymce) rich text editor is optional
        # 'imperavi',
        'sorl.thumbnail',
        ...
        'newsletter',
        ...
    )
    
  3. Configure any of the optional Settings.

  4. Import subscription, unsubscription and archive URL’s somewhere in your urls.py:

    urlpatterns = [
        ...
        url(r'^newsletter/', include('newsletter.urls')),
        ...
    ]
    
  5. Enable Django’s staticfiles app so the admin icons, CSS and JavaScript will be available where we expect it.

  6. Create the required data structure:

    ./manage.py migrate
    
  7. Change the default contact email listed in templates/newsletter/subscription_subscribe.html and templates/newsletter/subscription_update.html.

  8. (Optionally) Create message template overrides for specific newsletters in templates/newsletter/message/<newsletter_slug>/<message_type>[_subject].<html|txt> where <message_type> can be one from subscribe, unsubscribe, message or update.

  9. You may now navigate to the Django admin where the Newsletter module should be available for you to play with.

    In order to test if submissions work, make sure you create a newsletter, a subscription, a message and finally a submission.

    After creating the submission, you must schedule it by clicking the ‘submit’ button in the top right of the page where you edit it.

  10. Now you may perform a test submission with the submit_newsletter management command (-v 2 is for extra verbosity):

    ./manage.py submit_newsletter -v 2
    
  11. Add the submit_newsletter management command to crontab.

    For example (for sending every 15 minutes):

    */15  *  *   *   *     <path_to_virtualenv>/bin/python <project_root>/manage.py submit_newsletter 1>/dev/null 2>&1
    

To send mail, django-newsletter uses Django-provided email utilities, so ensure that email settings are properly configured for your project.