Simple user notification management for the Django web framework
Project description
Usage
1. create notification events
from notifications.handlers import send_message
send_message('Mahmoud Liked your post', user, 'post_like')
Explain
# function interface
send_message(message:str, user:User, type:str)
# logic behind it
message: the text message to be sent to the user
user: an instance of User model (the one who will recieve the notification)
type: is a notification tag (you should create difrrent types in your system for different events)
2.fetch notifications using REST APIs
notifications/all/
:GET : get all the notifications
notifications/mark/
:PUT : mark all notifications as read
notifications/unread/
:GET: get all unread notifications
configration
Note: make sure that django chanels is up and runnnig and also you django serves under ASGI
INSTALLED_APPS = [
...
'channels', # django channels needs to be installed
'notifications', # our package
...
]
SIMPLE_NOTIFICATION_SETTINGS = {
'receive_handler_path': 'custom_module.custom_py_file.custom_receive_handler',
}
AUTH_USER_MODEL = "users.User"
path('api/v1/notifications/', include('notifications.urls')),
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-simple-notification-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d37fe94d9fa0d16280d2ff48ac66792831e3c2e03581dcc353b60a20ebeb4959 |
|
MD5 | cf6b5c12f4933395d70f692bb137e291 |
|
BLAKE2b-256 | 2feb4bb077264e3ae863e85638cd55a84f2b647092807d53869da9b01fc603e8 |