django-notifications-hq
raw JSON → 1.8.3 verified Fri May 01 auth: no python
A GitHub-like notifications app for Django. Current version 1.8.3. Supports Django 3.2, 4.1+. Released infrequently, maintenance mode.
pip install django-notifications-hq Common errors
error ImportError: cannot import name 'notify' from 'notifications' ↓
cause Incorrect import path; notify is in signals module.
fix
Use: from notifications.signals import notify
error django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: notifications ↓
cause Another app named 'notifications' is installed (e.g., django-allauth's notification).
fix
Rename your app or use a different INSTALLED_APPS label, or set NOTIFICATIONS_LABEL in settings.
Warnings
breaking Version 1.5.0 introduced a required DJANGO_NOTIFICATION_CONFIG dict in settings.py. Old configs broken. ↓
fix Add DJANGO_NOTIFICATION_CONFIG = {'PAGINATE_BY': 20, 'USE_JSONFIELD': False, 'SOFT_DELETE': False, 'NUM_TO_FETCH': 10} to settings.py.
deprecated Django <3.2 and Python <3.7 support dropped in 1.8.0. ↓
fix Upgrade to Django 3.2+ and Python 3.7+.
gotcha The notify.js callback uses class-based selectors since version 1.4.0. Old ID-based selectors break if you override templates. ↓
fix Use CSS classes instead of IDs in custom templates.
Imports
- notify wrong
from notifications import notifycorrectfrom notifications.signals import notify - Notification
from notifications.models import Notification
Quickstart
INSTALLED_APPS = [
'notifications',
# ...
]
from django.conf import settings
from notifications.signals import notify
# Create a notification
notify.send(request.user, recipient=other_user, verb='reached level 10')
# In template
{% load notifications_tags %}
<script src="{% static 'notifications/notify.js' %}" type="text/javascript"></script>
{% register_notify_callbacks callbacks='fill_notification_badge,fill_notification_list' %}
{% live_notify_badge %}
{% live_notify_list %}