Skip to main content

A Django app to manage newsletter subscriptions

Project description

diddemo-newsletter

Demo Newsletter is a Django app that manages your newsletter subscriptions

Quick start:

  1. Add "newsletter" to your INSTALLED_APPS setting like this.

    INSTALLED_APPS = [ ... 'newsletter', ]

  2. Include the polls URLconf in your project urls.py like this.

    path('', include('newsletter.urls', namespace="news")),

  3. Run "python manage.py migrate" to create the NewsLetter models.

Optional settings:

  1. NL_REDIRECT_HTML

    Defailts to 'news/news_letter.html'. You can overwrite this settings by adding NL_REDIRECT_HTML = 'your_html_location' to your settings.py file.

  2. UNSUBSCRIBE_DICT

    Defaults to {}. You can overwrite this setting by adding UNSUBSCRIBE_DICT = { "1": "Your first unsubscribe reason", "2": "Your second unsubscribe reason", "3": "Your third unsubscribe reason", "4": "Your forth unsubscribe reason" }, to your settings.py file.

    Note: "Not specified" will be used when KeyError is raised when processing an unsubscribe request

Note: More settings coming soon

Configuration:

Main model: NewsLetter Model form: NewsLetterForm - the form has an email field only TemplateTag: {% nl_unsubscribe email=user_email reason=your_reason_key %}

  1. Code example:

    views.py:

     from django.views.generic.edit import FormView
     from newsletter.forms import NewsLetterForm
    
     class ExampleView(FormView):
    
     	template_name = "example.html"
     	form_class = NewsLetterForm
     	success_url = "/news-letter"
    
     	def form_valid(self, form):
     		form.save()
     		return super().form_valid(form)
    

    urls.py:

     from django.urls import path
     from . import views
    
     app_name = "your_app_name"
    
     urlpatterns = [
     	path("example", views.ExampleView.as_view(), name="example"),
    

    example.html:

     <form class="your-classes" id="newsletterform" method="POST">
       {% csrf_token %}
       <input type="email" class="your-classes" placeholder="Your email address.."  id="{{form.email.id_for_label}}" name="{{form.email.name}}">
       <button class="your-classes" type="submit">Subscribe</button>
     </form>
    

    Your email html:

    {% load news_tags %}

    ...
      <a href="{% nl_unsubscribe email=email_address reason=reason_key %}">unsubscribe</a>
    

    ...

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-manage-newsletter-0.0.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

django_manage_newsletter-0.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file django-manage-newsletter-0.0.1.tar.gz.

File metadata

  • Download URL: django-manage-newsletter-0.0.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3

File hashes

Hashes for django-manage-newsletter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 dcd54451e86c9b1986e7aacc7127ea1dbb823b39a492a51c2622901a6c1f805b
MD5 6494d49679536cc30ae5d7377913dd75
BLAKE2b-256 fa23ea3222354fecdb76aaaf90085c245707b3f8cacb04fca5fbcecf8b707c31

See more details on using hashes here.

File details

Details for the file django_manage_newsletter-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_manage_newsletter-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3

File hashes

Hashes for django_manage_newsletter-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b4e47a151934e71488ffc40d0c19e156b689b7e6f068fcc3232bef2f8668bd4
MD5 aa102b06c1cc99a4f7ac7793235c472c
BLAKE2b-256 f84060c5c2ecea7d9aa1fd7f81a7c19c70703de16f8f840016d9510d03c2ceb8

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