Getting Started


Getting the code

The recommended way to install django-vox is via pip (on Windows, replace pip3 with pip)

$ pip3 install django-vox[markdown,twilio,html]

Configuring Django

Add 'django_vox' to your INSTALLED_APPS setting:

    # ...

Additionally, you may want to configure certain backends depending on exactly what sort of other notifications you want.

The Demo

While you’re welcome to use the setup instructions here, it may be easier to just try out the demo that comes with this package. The demo doesn’t cover all the use cases (yet) but it does cover most of the standard stuff.

Setting up the Models

There’s basically two parts to setting up the models. First, you have to add notifications to the models that you want notifications about. Second, you have to add channels to those notifications to specify where they can be sent. Finally, you need to implement the AbstractContactable interface for whatever your channels return so that we now how to contact them.

If you only ever want to send notifications to the site contacts, you can skip step 2 and 3, but that’s not very fun, is it.

Adding Model Notifications

Notifications in django vox are centered around models. This is important, because it makes it possible to predictably know what parameters will be available in the notification templates, and provides a measure of sanity to whoever is editing them.

To add notifications to a model, change the parent class from django.db.models.Model to django_vox.models.VoxModel. Also, add VoxMeta inner class (much like django’s Meta) which contains an attribute, named notifications. Set it to a VoxNotifications object, and each parameter you pass to it will specify the parameters for another notification. The parameter keys are the notification’s codename and the values are the the description (if they’re a plain string) or you can use a VoxNotification object to specify more parameters.

class User(VoxModel):

    class VoxMeta:
        notifications = VoxNotifications(
            create=_('Notification to that a user created an account'),


    def save(self, *args, **kwargs):
        new = is None
        super().save(*args, **kwargs)
        if new:


class PurchaseOrder(VoxModel):

    class VoxMeta:
        notifications = VoxNotifications(
            received = _('Notification that an order was received.'),
            on_hold = _('Notification that an order is on hold.'),

    def save(self, *args, **kwargs):
        new = is None
        if not new:
            old = PurchaseOrder.objects.get(
        super().save(*args, **kwargs)
        if new:
        if not new and not old.on_hold and self.on_hold:

Here’s an example of the long-winded form to specify your parameters, This is more verbose, but makes it easier to specify extra notification parameters (like actor & target model) if you need them.

class User(VoxModel):

    class VoxMeta:
        notifications = VoxNotifications(
                _('Notification to that a user created an account'),

Once you’ve finished adding these, you’ll need to regenerate the notifications table using the make_notifications management command:

python3 make_notifications

Adding Channels

Channels are what allow you to select different recipients. The site contacts channel is available by default, but if you want any other channels, you have to create them yourself using the channel registry at django_vox.registry.channels. You can add new channels using either the add or add_self method takes four arguments:

A slug that identifies the channel. Should be unique per model.
A name that shows up in the admin. Optional, defaults to various automatic values.
Model class of the objects returned by the function. Optional, defaults to the VoxModel subclass (i.e. Foo in Foo.add_channel).
A function or method that returns the instances of recipient_type. The function is called with a single argument which is the VoxModel instance that will eventually use it (i.e. the content object). Optional, defaults to lambda x: x

An example of channels given the above code might look like this:

class PurchaseOrder(VoxModel):
    def get_purchasers(self):
        yield self.purchaser

    def get_managers(self):


from django_vox.registry import channels
channels[PurchaseOrder].add('purchaser', _('Purchaser'), User,
channels[PurchaseOrder].add('manager', _('Manager'), User,

Adding Contact Info

Now we have to implement the get_contacts_for_notification(notification) method for all the things that are return in channels. In our above example, that’s just the User model. This method takes a notification, and returns all of the contacts that the object has enabled for that notification. The idea behind this method is that it allows you to implement your own notification settings on a per-contact basis.

For now, we’re just going to make an implementation that assumes every user will get email notifications for all notifications. We can alter the user class to look like this:

from django_vox.models import VoxModel
from django_vox.base import Contact

class User(VoxModel):
    email = models.EmailField(max_length=254, unique=True)

    def get_contacts_for_notification(notification):
        return Contact(, 'email',


We haven’t covered actors or targets, but this example should be enough to get you started.

And there you have it. Now, in order for this to do anything useful, you’ll need to add some appropriate templates. In this case, you’ll want an email template for the “User” recipient of the “user created” notification, and possibly a template for a site contact too.