Django message notification package
Project description
Django user notification
Overview
Django user notification is intended to provide a way to send multiple types of notification messages to django users out of box and docs are on the way...
Requirements
- Python (3.8, 3.9, 3.10)
- Django (3.0, 3.1, 3.2, 4.0, 4.1)
We highly recommend and only officially support the latest patch release of each Python and Django series.
Installation
Install using pip
...
pip install django-user-notification
Add 'notification'
to your INSTALLED_APPS
setting.
INSTALLED_APPS = [
...
'notification',
]
Quick Start
Let's take a look at a quick start of using Django user notification to send notification messages to users.
Run the notification
migrations using:
python manage.py migrate notification
Add the following to your settings.py
module:
INSTALLED_APPS = [
... # Make sure to include the default installed apps here.
'notification',
]
DJANGO_USER_NOTIFICATION = {
"aliyunsms": {
"access_key_id": "ACCESS_KEY_ID",
"access_key_secret": "ACCESS_KEY_SECRET",
"sign_name": "SIGN_NAME",
},
"dingtalkchatbot": {
"webhook": "DINGTALK_WEBHOOK",
},
"dingtalkworkmessage": {
"agent_id": "DINGTALK_AGENT_ID",
"app_key": "DINGTALK_APP_KEY",
"app_secret": "DINGTALK_APP_SECRET",
},
"dingtalktodotask": {
"app_key": "DINGTALK_APP_KEY",
"app_secret": "DINGTALK_APP_SECRET",
},
}
Let's send a notification
from django.contrib.auth import get_user_model
from notification.backends import notify_by_email, notify_by_dingtalk_workmessage
User = get_user_model()
recipient = User.objects.first()
# send a dingtalk work message notification
notify_by_dingtalk_workmessage([recipient], phone_field="phone", title="This is a title", message="A test message")
# send a email notiofication
notify_by_email([recipient], title="This is a title", message="A test message")
Send Message With Template
django-user-notification
support send notifications with custom template, To
specify a custom message template you can provide the template_code
and context
parameters.
-
Create a template message with code named
TMP01
on django admin -
Provide the
template_code
andcontext
tosend
method:
...
notify_by_email([recipient], template_code="TMP01", context={"content": "Hello"})
Supported backends
DummyNotificationBackend
: send dummy messageEmailNotificationBackend
: send email notification.WebsocketNotificationBackend
: send webdocket notification, needchannels
installedAliyunSMSNotificationBackend
: send aliyun sms notification.DingTalkChatBotNotificationBackend
: send dingtalk chatbot notification.DingTalkTODOTaskNotificationBackend
: send dingtalk todo tasks notificationDingTalkWorkMessageNotificationBackend
: send dingtalk work message notification.
Running the tests
To run the tests against the current environment:
$ ./manage.py test
Changelog
0.5.0
- Initial release
Thanks
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-user-notification-0.7.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 814890396f8e0d69fbadc82781488115d0f7f28c9d63add92858083ebfef043f |
|
MD5 | ae3bdbe3169fbf7e7a567fa14580004c |
|
BLAKE2b-256 | 83d95eb1f3496602e37603c55dd13540548affd5d97ffaa4f23990e38780246f |
Hashes for django_user_notification-0.7.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8050c70dde46ce8d5707f1d3735c1b2a0df12a1efe0b4e39f05083e4e53f4c56 |
|
MD5 | 2ce63e88c3a15c3b98464558ae27244d |
|
BLAKE2b-256 | 77596d1dc19dcda28f491953d1daa9a4af6457f73a00cd469effbb63d3911f91 |