Django notification on comment submission

雨燕双飞 提交于 2019-12-04 12:40:19

Connect django.contrib.comments.signals.comment_was_posted to notification.models.send() as appropriate.

You have to register your comment_notification function with comment_was_posted signal.

from django.contrib.comments.signals import comment_was_posted

if "notification" in settings.INSTALLED_APPS:
    from notification import models as notification

    def comment_notification(sender, comment, request):
        user = request.user
        message = "123"
        notification.send([user], "new comment", {'message': message,}) 

    comment_was_posted.connect(comment_notification)

I don't know of an app (pretty sure there'll be something out there) but it is fairly straightforward to roll your own. You can tap the Comment model's comment_was_posted signal to call a function that will send you an email.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!