Preferences about notifications can be set per user and per group.

Group Preferences

Per group preferences can be set so that if a user belongs to any group that has the the preference set to True, then a notification is sent, unless it is overridden by user preference.

Group preferences are stored in the GroupPrefs model.


User Preferences

Per user preferences override per group preferences. The user preference for a notification can only be set if the user has all the permissions required for that notification.

User preferences are stored in the UserPrefs model.


Set Preferences

# User
notification_obj.update_user_prefs(user_obj, {'email': True, 'backend2': False})
# Group
notification_obj.update_group_preference(group_obj, {'email': True, 'backend2': False})

# or use a shortcut method
from notifier.shortcuts import update_preferences
# User
update_preferences('notification-name', user_obj, {'email': True, 'backend2': False})
# Group
update_preferences('notification-name', group_obj, {'email': True, 'backend2': False})
notifier.shortcuts.update_preferences(name, user, prefs_dict)[source]



notification name (string)


user or group object


dict with backend obj or name as key with a boolean value.

e.g. {‘email’: True, ‘sms’: False}, {email_backend_obj: True, sms_backend_obj: False}


dict with backend names that were created or updated. values that do not require change are skipped

e.g. {‘email’: ‘created’, ‘sms’: updated}

Clear Preferences

There is a shortcut method to clear all user preferences (set preferences back to default)

from notifier.shortcuts import clear_preferences
clear_preferences([user1, user2])


users:user object or list of user object




django-notifier has a formset that includes a form for every notification along with checkboxes for every backend for that notification. This can be used in a view to allow the users to set notification preferences.


An example of customizing the formset in django templates:

{% load attribute %}

{% if formset.forms %}
<form id="notification_form" name="input" method="post" autocomplete="off" class="form">
    {% csrf_token %}
    {{ formset.management_form }}
    <div class="form_item table"><table>
            {% for method in %}
                <th>{{ method.display_name }}</th>
            {% endfor %}
        {% for form in formset %}
                    <div class="form_label">{{ form.title }}</div>
                {% for method in %}
                        {% with field=form| %}
                            {% if field %} {{ field }} {% endif %}
                        {% endwith %}
                {% endfor %}
        {% endfor %}

    <div class="form_item">
        <div class="two-button">
            <input type="submit" value="Save">
{% else %}
<p>There are no notifications that can be configured.</p>
{% endif %}