A Django app to different handle basic notifications.
Project description
Django Dans Notifications
Description
A Django app to handle notifications.
Support for basic notifications, push notifications and email notifications.
Quick start
- Install the package via pip:
pip install django-dans-notifications
- Add "django_dans_notifications" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'django_dans_notifications',
]
- Include the URL configs in your project
urls.py
for the REST API endpoints like this:
path("api/notifications/", include("django_dans_notifications.urls")),
-
Run
python manage.py migrate
to update your database schema. -
Use the API endpoints, in code or your Django admin portal.
Requirements
- Python 3.8 or higher
- Django 3.1 or higher
- Django Rest Framework
- NOTE: not only must you have this installed, you must have set
DEFAULT_AUTHENTICATION_CLASSES
andDEFAULT_PAGINATION_CLASS
in yoursettings.py
to work with the APIs properly. An example config would be:
- NOTE: not only must you have this installed, you must have set
REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
"PAGE_SIZE": 20,
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.TokenAuthentication",
),
}
Available Settings
Currently all available settings are optional:
TEAM_NAME
- Default team name to use for emails, can be added to message context manually as well still.IN_TEST
- Whether running in tests or not. Used to determine whether to actually send email.
Add these to your settings.py
file to customize the app's behavior like so:
TEAM_NAME = "My Team"
IN_TEST = True
Usage
The main way to interact with this app is to create and use the appropriate models and their managers' methods as needed.
Also included is the NotificationManager
a class to expose some common functionality and maintain object permissions.
Some of its methods currently are:
- get_notifications_push/email/basic/all
- Enforce object ownership and notification 'direction'
- mark_notification_basic_read
You can also interact directly, so for example to send an email notification:
from django_dans_notifications.models import EmailNotification
email_notification = EmailNotification.objects.send_email(...)
Docs
Model docs.
API docs.
Email Template docs.
https://danielnazarian.com
Copyright 2024 © Daniel Nazarian.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-dans-notifications-1.1.17.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcef038854af0e8ef9c73fe3f9d766df5b433681d21d13d9c1247cda8581ada4 |
|
MD5 | ab52f1afbad7128bf7fa64c08a8ff434 |
|
BLAKE2b-256 | 63abbe743fc0a28a19e2eb061a1ac860508d7707dc5c9005ee83640351f9f2d8 |
Hashes for django_dans_notifications-1.1.17-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e03437345e5c8b34ef409d0078b9a79498fe2aaee7da6e57a6d0167be975abdd |
|
MD5 | e488d2e08d82a965a9baeb44de731f62 |
|
BLAKE2b-256 | 1ed1c3a12352c5aec94b43e2657209457aef61200961d88d8cff9a9c5a94658e |