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 'tinymce' and 'notification' to your INSTALLED_APPS setting.
INSTALLED_APPS = [
'django.contrib.admin',
...
'tinymce',
'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.
'tinymce',
'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",
},
}
Add tinymce.urls to urls.py for your project:
urlpatterns = [
...
path('tinymce/', include('tinymce.urls')),
...
]
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
TMP01on django admin -
Provide the
template_codeandcontexttosendmethod:
...
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
Metadata
Release files for django-user-notification 0.10.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_user_notification-0.10.2.tar.gz | 19.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_user_notification-0.10.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.9 kB
Release files / django_user_notification-0.10.2.tar.gz
| Download URL | django_user_notification-0.10.2.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30dc84011a5b261f1f4da983bef53c87ace0f83e0f5e920d6c4fec477e7c2805
|
|
BLAKE2b-256 checksum How to use checksums |
ca005638112a042584feee5b35336a026dad225d92e9e20a221328aa52148edd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.3 Darwin/22.5.0
|
Release files / django_user_notification-0.10.2-py3-none-any.whl
| Download URL | django_user_notification-0.10.2-py3-none-any.whl |
|---|---|
| Size | 30.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79621f0da6a6e37e5e3c733310cafeec74d906cfe22979ef8b8c507a6755cd19
|
|
BLAKE2b-256 checksum How to use checksums |
370f9d8b59b6bbd649f0b55c58ad2e7657c7cc61427d081b23b234e971c200ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.3 Darwin/22.5.0
|
Security for django-user-notification 0.10.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.