• Stars
    star
    189
  • Rank 204,649 (Top 5 %)
  • Language
    Python
  • Created about 15 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An app for sending newsletter by email to a contact list.

Emencia Django Newsletter

The problematic was :

How to couple a contact base to a mailing list and sending newsletters throught Django ?

Imagine that we have an application containing some kind of profiles or something like the django.contrib.auth and you want to send newsletters to them and tracking the activity.

Features

More than a long speech, here the list of the main features :

  • Coupling capacities with another django model.
  • Variables can be used in the newsletter's templates.
  • Mailing list managements (merging, importing...).
  • Import/Export of the contact in VCard 3.0.
  • Configurable SMTP servers with flow limit management.
  • Working groups.
  • Can send newsletter previews.
  • Subscriptions and unsubscriptions to mailing list.
  • Attachments in newsletters.
  • Unique urls for an user.
  • Tracking statistics.

Architecture

At the level of the application architecture, we can see 2 originalities who need to be explained.

Content types

The content types application is used to link any Contact model instance to another model instance. This allow you to create different kinds of contact linked to differents application, and retrieve the association at anytime.

This is particulary usefull with the templates variables if certain informations are located in the model instance linked.

Cronjob/Command

The emencia.django.newsletter application will never send the newsletters registered in the site until you launch the send_newsletter command.

$ python manage.py send_newsletter

This command will launch the newsletters who need to be launched accordingly to the credits of the SMTP server of the newsletter. That's mean that not all newsletters will be expedied at the end of the command because if you use a public SMTP server you can be banished temporarly if you reach the sending limit. To avoid banishment all the newsletters are not sended in the same time and immediately.

So it is recommanded to create a cronjob for launching this command every hours for example.

Installation

Dependencies

Make sure to install these packages prior to installation :

  • Django >= 1.2
  • html2text
  • BeautifulSoup
  • django-tagging
  • vobject
  • xlwt
  • xlrd

The package below is optionnal but handy for rendering a webpage in your newsletter.

  • lxml

Getting the code

You could retrieve the last sources from http://github.com/Fantomas42/emencia-django-newsletter and running the installation script

$ python setup.py install

or use pip

$ pip install -e git://github.com/Fantomas42/emencia-django-newsletter.git#egg=emencia.django.newsletter

For the latest stable version use easy_install

$ easy_install emencia.django.newsletter

Applications

Then register emencia.django.newsletter, admin, contenttypes and tagging in the INSTALLED_APPS section of your project's settings.

INSTALLED_APPS = (
  # Your favorites apps
  'django.contrib.contenttypes',
  'django.contrib.sites',
  'django.contrib.admin',
  'django.contrib.sessions',
  'tagging',
  'emencia.django.newsletter',)

Urls

In your project urls.py adding this following line to include the newsletter's urls for serving the newsletters in HTML.

url(r'^newsletters/', include('emencia.django.newsletter.urls')),

Note this urlset is provided for convenient usage, but you can do something like that if you want to customize your urls :

url(r'^newsletters/', include('emencia.django.newsletter.urls.newsletter')),
url(r'^mailing/', include('emencia.django.newsletter.urls.mailing_list')),
url(r'^tracking/', include('emencia.django.newsletter.urls.tracking')),
url(r'^statistics/', include('emencia.django.newsletter.urls.statistics')),

Media Files

You have to make a symbolic link from emencia/django/newsletter/media/edn/ directory to your media directory or make a copy named edn, but if want to change this value, define NEWSLETTER_MEDIA_URL in the settings.py as appropriate.

Don't forget to serve this url.

Synchronization

Now you can run a syncdb for installing the models into your database.

Settings

You have to add in your settings the email address used to send the newsletter :

NEWSLETTER_DEFAULT_HEADER_SENDER = 'My NewsLetter <[email protected]>'

DBMS considerations

It's not recommended to use SQLite for production use. Because is limited to 999 variables into a SQL query, you can not create a Mailing List greater than this limitations in the Django's admin modules. Prefer MySQL ou PgSQL.

HOWTO use TinyMCE for editing the newsletters

It can be usefull for the end user to have a WYSIWYG editor for the creation of the newsletter. The choice of the WYSIWYG editor is free and the described method can be applied for anything, but we will focus on TinyMCE because he has many features and a usefull plugin for loading templates within it.

First of all install the django-tinymce application into your project.

That's done, enjoy !

HOWTO couple your profile application with emencia.django.newsletter

If you wan to quickly import your contacts into a mailing list for example, you can write an admin's action for your model.

We suppose that we have the fields email, first_name and last_name in a models name Profile.

In his AdminModel definition add this method and register it into the actions property.

class ProfileAdmin(admin.ModelAdmin):

    def make_mailing_list(self, request, queryset):
        from emencia.django.newsletter.models import Contact
        from emencia.django.newsletter.models import MailingList

        subscribers = []
        for profile in queryset:
            contact, created = Contact.objects.get_or_create(email=profile.mail,
                                                             defaults={'first_name': profile.first_name,
                                                                       'last_name': profile.last_name,
                                                                       'content_object': profile})
            subscribers.append(contact)
        new_mailing = MailingList(name='New mailing list',
                                  description='New mailing list created from admin/profile')
        new_mailing.save()
        new_mailing.subscribers.add(*subscribers)
        new_mailing.save()
        self.message_user(request, '%s succesfully created.' % new_mailing)
    make_mailing_list.short_description = 'Create a mailing list'

    actions = ['make_mailing_list']

This action will create or retrieve all the Contact instances needed for the mailing list creation.

After this you can send a newsletter to this mailing list.

Development

A Buildout script is provided to properly initialize the project for anybody who wants to contribute.

First of all, please use VirtualEnv to protect your system.

Follow these steps to start the development :

$ git clone git://github.com/Fantomas42/emencia-django-newsletter.git
$ virtualenv --no-site-packages emencia-django-newsletter
$ cd emencia-django-newsletter
$ source ./bin/activate
$ python bootstrap.py
$ ./bin/buildout

The buildout script will resolve all the dependancies needed to develop the application.

Once these operations are done, you are ready to develop on the project.

Run this command to launch the tests.

$ ./bin/test

Or you can also launch the demo.

$ ./bin/demo syncdb
$ ./bin/demo runserver

Pretty easy no ?

Translations

If you want to contribute by updating a translation or adding a translation in your language, it's simple: create a account on Transifex.net and you will be able to edit the translations at this URL :

http://www.transifex.net/projects/p/emencia-django-newsletter/resource/djangopo/

http://www.transifex.net/projects/p/emencia-django-newsletter/resource/djangopo/chart/image_png

The translations hosted on Transifex.net will be pulled periodically in the repository, but if you are in a hurry, send me a message.

Database Representation

https://github.com/Fantomas42/emencia-django-newsletter/raw/master/docs/graph_model.png

More Repositories

1

django-local-ai

Run a local AI from Django with Llama.cpp
Python
12
star
2

emencia-django-tracking

Track activities on your models for displaying the site activity in your Django projects.
Python
10
star
3

django-blog-lotus

A weblog application with Django.
Python
8
star
4

emencia-django-socialaggregator

Django app for aggregate some feeds from social networks
Python
7
star
5

locallm

An api to query local language models using different backends
Python
6
star
6

emencia-django-directory

Generic directory application written for Django
Python
5
star
7

Epaster

Buildout projects builder with Paste and Buildout
Python
5
star
8

emencia-django-ged

Very simple DMS application for Django
Python
5
star
9

emencia-django-slideshows

A Django application to make slideshows
Python
5
star
10

porticus

Yet another File gallery for Django
Python
4
star
11

cookiecutter-djangocms3-buildout

Cookiecutter template to make a Buildout structure for a complete Django CMS site
CSS
4
star
12

emencia-django-countries

List of manageable countries for your Django projects
Python
3
star
13

cmsplugin-porticus

Porticus plugins for DjangoCMS
Python
2
star
14

cmsplugin-blocks

A set of DjangoCMS plugins for structured contents in CMS pages
Python
2
star
15

emencia-django-french_zones

French regions and departments utilities for your Django projects
Python
2
star
16

django-datastack

A data analytics stack for Django
Python
2
star
17

emencia-cms-snippet

This is a "cms.plugins.snippet" (from DjangoCMS) clone to extend it with some facilities
Python
2
star
18

djangoapiforms

A composable to handle Django forms in json
TypeScript
2
star
19

cmsplugin-slideshows

emencia-django-slideshows plugins for DjangoCMS
Python
1
star
20

emencia-django-forum

A minimalistic Django forum app
CSS
1
star
21

django-localizer

Python
1
star
22

django-firm-info

A Django application package for storage firm info
Python
1
star
23

cookiecutter-djangocms-plugin

A Cookiecutter template to produce a basic Django CMS plugin
Python
1
star
24

ckeditor-vimeo-plugin

CKEditor Plugin to embed Vimeo videos.
JavaScript
1
star
25

emencia-django-training

1
star
26

runplaywright

A tests runner for Playwright
JavaScript
1
star
27

emencia-django-stylish

Apply style attributes to HTML markups
Python
1
star
28

emencia_paste_djangocms_3

Epaster template to build DjangoCMS 3.x projects
CSS
1
star
29

django-xiti

Django app to include Xiti loading code into your templates
Python
1
star
30

diskette

💾 Export and import Django application data and medias
Python
1
star