Search code examples
djangodjango-modelsdjango-signalsdjango-comments

Django notification on comment submission


I am making use of Django's contrib.comments and want to know the following.

Are there any utils or app out there that can be plugged into an app that sends you a notification when a comment is posted on an item?

I haven't really worked with signals that much, so please be a little bit descriptive.

This is what I came up with.

from django.contrib.comments.signals import comment_was_posted
from django.core.mail import send_mail

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

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

    comment_was_posted.connect(comment_notification)

Solution

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