Say user a liked user b. I want to show this as a notification in the notification panel of user b when she logs in. She can also view her previous notifications (basically like facebook notification). This is not email notification
or a success/warning
type one time notification.
I want to know the right track to follow. Do I use django-notifications
or django-messages-framework or push notifications
? Where is the use of channels
and web sockets
in all of these?
My steps:
1) create a notification app
2) create a notification model (what fields do I put here if since django-notification
already has actor, verb, action object and target
fields?)
3) Do i have to create forms.py
? How is the notification message getting passed?
4) What view do I put in views.py
? (please give an example code)
If there is any example project that implemented the notification system
please provide a link.
If you're using django-notifications you can just create an object with the actor as user_a, verb as 'like
' or any other action performed, recipient would be user_b
So something like
notify.send(request.user, verb='liked', recipient=[target_user])
When user_b logs in you can fetch all the notification (or maybe just the unread ones) and display it
user.notifications.active()
user.notifications.unread()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.