Skip to main content

A model agnostic Django newsletter app integrating Mosaico.

Project description

# Nuntius

Nuntius is a newsletter application for Django.

Nuntius integrates with your Django project.
It is very agnostic about your subscribers and subscriber lists models.

It features [Mosaico](, a drag-and-drop email
editor, for sending beautiful emails to your subscribers.

## How it works

Nuntius is agnostic about your subscribers model. You can use your current
use model, as long as it implements a few required methods.

To allow your end-users to choose recipients, it is your choice to implement
one or more "segment" models. Segment models implement a required method

You can then create campaigns in the Django admin panel, and send them to
existing segments.

Celery is used to queue and send emails. Nuntius must have its own celery worker.

## Installation

1. Add "nuntius" to your INSTALLED_APPS setting like this:
2. Include Nuntius urlconf in your project `` like this:
path('nuntius/', include('nuntius.urls')),
3. Edit or create your subscriber model so it works with Nuntius.
You must implement all the methods from
An easy way to do this is to extend `BaseSubscriber` and to create a
`subscriber_status` `IntegerField` and an `email` `EmailField`, but
you can implement the methods the way you want, using Nuntius `BaseSubscriber`
as documentation.

Here is the most basic implementation you can do :

# myapp.models.MySubscriberModel
from nuntius.models import BaseSubscriber
from django.db import models
from django.db.models import fields

class MySubscriberModel(BaseSubscriber, models.Model):
email = fields.EmailField(max_length=255)
subscriber_status = fields.IntegerField(choices=BaseSubscriber.STATUS_CHOICES)

4. Set the two required settings in your ``
NUNTIUS_SUBSCRIBER_MODEL = 'myapp.MySubscriberModel'

5. Launch Redis and celery in the background. In production, you should probably use systemd for this.
The command for celery should be something like this :
export DJANGO_SETTINGS_MODULE=myapp.settings
celery -A nuntius.celery worker

Unless you are using a custom admin site, admin panels for Nuntius will be
and added to you admin site.

## Advanced usage

### List segments

If you want to have more control on your recipients, you can create
segment models.

One example of segment is a simple model which holds a Many-to-Many relation
to subscribers.

Another example is a segment model which filters subscribers depending on
the date of their last login :

from django.db import models
from django.db.models import fields
from datetime import datetime

from nuntius.models import BaseSegment

class LastLoginDateSegment(BaseSegment, models.Model):
last_login_duration = fields.DurationField()

def get_display_name(self):
return f'Last login : {str( - self.last_login_duration)}'

def get_subscribers_queryset(self):
return MySubscriberClass.objects.filter( - self.last_login_duration)

def get_subscribers_count(self):
return MySubscriberClass.objects.filter( - self.last_login_duration, subscribed=True)


* `get_subscribers_queryset` is allowed to return subscribers regardless of their
`subscriber_status`, as `get_subscriber_status` will be called on each instance.
* `get_subscribers_count` is only there for convenience in the admin panel, it does not
have to be accurate. If you want to have it accurate, you should however take
your subscribers status into account.

Then, add your segment model(s) to Nuntius settings :
NUNTIUS_SEGMENT_MODELS = ['myapp.lastlogindatesegment']

### ESP and Webhooks

Maintaining your own SMTP server to send your newsletter is probably
a bad idea if you have more than a few subscribers. You can use
[Anymail]( along with Nuntius
in order to use an email service provider. Anymail supports
a lot of ESP, like Amazon SES, Mailgun, Mailjet, Postmark, SendGrid,
SendinBlue, or SparkPost.

Refer to the steps in [Anymail 1-2-3](
to install Anymail. If you want to configure Anymail just for Nuntius and keep
the default email backend for other usage, you can use the setting `NUNTIUS_EMAIL_BACKEND`
rather than the default `EMAIL_BACKEND`.

In addition, configuring Nuntius with Anymail will allow you to use ESP tracking features
and to track status of your email once it is sent.

#### Webhooks

Configuring webhhoks allows Nuntius to track email status and to
give you statistics on campaign, as well as updating subscriber status
when they bounce.

1. Configure email tracking as described in
[Anymail documentation](
2. Implement the method `set_subscriber_status(self, email, status)` on your subscriber
model manager.

Nuntius will automatically listen to Anymail signals and call this method approprietly.

## License

Copyright is owned by Guillaume Royer and Arthur Cheysson.

You can use Nuntius under GPLv3 terms.

Project details

Download files

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

Files for nuntius, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size nuntius-0.2.0-py3-none-any.whl (5.3 MB) File type Wheel Python version py3 Upload date Hashes View
Filename, size nuntius-0.2.0.tar.gz (2.6 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page