Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Allow everybody to unsubscribe your messages, user accounts are not required.

Project description

https://img.shields.io/pypi/v/django-opt-out.svg https://img.shields.io/travis/wooyek/django-opt-out.svg Documentation Status Coveralls.io coverage CodeCov coverage Maintainability License Tweet about this project https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg

Allow everybody to unsubscribe your messages, user accounts are not required.

Features

  • A single page form for opt-out feedback submission
  • Feedback options text controlled from django admin
  • Predefined feedback defaults available from django manage command
  • Feedback translations done in django admin
  • Feedback options selection based on tags supplied to the opt-out url
  • Ability to preselect a feedback option
  • Ability to change selected feedback options after submission
  • Ability to set tag:value pair on opt-out url and store them on submission with user feedback
  • Signal to modify opt-out form before rendering
  • Signal on opt-out feedback submission
  • Easily overridable thank you / goodbye view
  • Opt-out form with a easily overridable base template

Demo

To run an example project for this django reusable app, click the button below and start a demo serwer on Heroku

Deploy Django Opt-out example project to Heroku Deploy Django Opt-out example project to Heroku

Quickstart

Install Django Opt-out application:

pip install django-opt-out

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'django_opt_out.apps.DjangoOptOutConfig',
    ...
)

Add Django Opt-out application’s URL patterns:

from django_opt_out import urls as django_opt_out_urls


urlpatterns = [
    ...
    url(r'^', include(django_opt_out_urls)),
    ...
]

Add unsubscribe links to your emails:

from django_opt_out.utils import get_opt_out_path
email='Django Opt-out <django-opt-out@niepodam.pl>'
unsubscribe = get_opt_out_path(email, 'some', 'tags', 'controlling', 'questionnaire')

# unsubscribe link will not have a domain name and scheme
# you can build prefix from request, but I prefer to set it in settings
from django.conf import settings
unsubscribe = settings.BASE_URL + unsubscribe
body = 'Hello, Regards\n\nUnsubscribe: ' + unsubscribe

from django.core import mail
message = mail.EmailMultiAlternatives(body=body, to=[email])
message.extra_headers['List-Unsubscribe'] = "<{}>".format(unsubscribe)
message.send()

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

This package was created with Cookiecutter and the wooyek/cookiecutter-django-app project template.

History

0.1.0 (2017-11-03)

  • First release on PyPI.

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django_opt_out-0.9.3-py2.py3-none-any.whl (35.2 kB) Copy SHA256 hash SHA256 Wheel 3.5 Apr 12, 2018
django-opt-out-0.9.3.tar.gz (196.7 kB) Copy SHA256 hash SHA256 Source None Apr 12, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page