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.
Documentation
on the way...
Requirements
- Python 3.8, 3.9, 3.10
- Django 3.1, 3.2, 4.0, 4.1
Installation
Install using pip
...
pip install django-user-notification
Add 'django_quill'
and 'notification'
to your INSTALLED_APPS
setting.
INSTALLED_APPS = [
'django.contrib.admin',
...
'django_quill',
'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.
'django_quill',
'notification',
]
DJANGO_USER_NOTIFICATION = {
"aliyunsms": {
"access_key_id": "Your Access Key ID",
"access_key_secret": "Your Access Key Secret",
"sign_name": "Your Sign Name",
},
"dingtalkchatbot": {
"webhook": "Your Webhook URL",
},
"dingtalkworkmessage": {
"agent_id": "Your App Agent ID",
"app_key": "Your App Key",
"app_secret": "Your App Secret",
},
"dingtalktodotask": {
"app_key": "Your App Key",
"app_secret": "Your 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, need install extension:channels
.AliyunSMSNotificationBackend
: send aliyun sms notification, need install extension:aliyunsms
.DingTalkChatbotNotificationBackend
: send dingtalk chatbot notification.DingTalkToDoTaskNotificationBackend
: send dingtalk todo tasks notificationDingTalkWorkMessageNotificationBackend
: send dingtalk work message notification.WechatNotificationBackend
: planning...
Running the tests
To run the tests against the current environment:
$ pytest tests/
Changelog
0.7.0
- Initial release
Contributing
As an open source project, we welcome contributions. The code lives on GitHub
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.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 087ffcb001155968478dd00aca3cd41276d63025e82153101826091eab8db020 |
|
MD5 | e84c3d49cd0ef5b7a8bf640a58b25066 |
|
BLAKE2b-256 | 8ada08253853fa2362cc9c71574d278f5ed07db743ded718cb7ba368c0e2828c |
Hashes for django_user_notification-0.7.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54d7803a5ae80c066f3c8449863fa923ba4c1981e89c2d26c3bebcbb654bbbc0 |
|
MD5 | d0e7d2b0f6c21dd9fdbbeb686e23a2cf |
|
BLAKE2b-256 | 3cf6ac2bf02bbd97250a006201193c29d197badc7f43855833f1fc4d5f9e5085 |