0

I have created a Django application where users are able to post, comment, and like each other's activity. I am now implementing sending out notifications when one user comments on another user's post, and I am able to do that using django-notifications. Although it is not as modular as I would like it to be, it gets the job done. Example of notification (views.py):

from notifications.signals import notify
...
notify.send(sender=request.user, recipient=post.user, verb='commented on your post', target=post)

I would like to send out notifications like "n users liked your post" (similar to Facebook notifications) and don't know how to do that. However, I found that django-notifications is rather outdated and I am considering whether I should switch to pinax-notifications if that package could help me out with this issue (tracking the change in the number of likes since recipient's last log in). How can I solve this?

EZbrute
  • 400
  • 2
  • 14
  • Do you keep track anywhere in code how likes are linked to posts? If so, you could count all the records and send that in a notification. Note that you would have to send out notifcation at a set time and not every time someone presses the like button. [ EDIT ] in Django based on a one2many field you could do something like 'post.likes.count()' to calculate the N. – JustLudo Jul 22 '20 at 11:20
  • Yes, I have defined models Post, Comment, and Review (which can be +1 or -1, equivalent to likes/dislikes) and I can easily get which user posted, commented, and reviewed. I get stuck at the part when to send out the notification. – EZbrute Jul 22 '20 at 11:25
  • In that case; my bad. I can't help you on that part. – JustLudo Jul 22 '20 at 11:31

0 Answers0