Django signals for Comment notification

I am working on django project and I have written a post_save signal to notify post author when commented. Now, I want to add a post_save signal to notify post author & comment user that a comment (reply) is made. How do I approach this? This is because there is a parent-child relationship on my comment model.

Below are my model and signal code. Can someone assist please? I am new on django and have just started learning django signals.

class Comment(models.Model):
 user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
 post = models.ForeignKey('forum.Post',related_name='comments', on_delete=models.CASCADE)
 reply = models.ForeignKey('self', null=True, blank=True, related_name='replies', on_delete=models.CASCADE)
 text = models.TextField(max_length=250, blank=True)

@receiver(post_save, sender=Comment)
def user_comment_post(sender, instance, created, **kwargs):
    if created:
        comment = instance
        post =
        #reply = comment.reply
        text_preview = comment.text[:90]
        sender = comment.user
        notify = Notification.objects.create(post=post, sender=sender, comment=comment,, text_preview=text_preview, notification_type=2)

I’m not sure I’m understanding the question here.

What you currently have:

  • When a comment is written on a post, create a Notification object for the author.

What you want to have happen:

  • When a comment is written on a post, create a Notification object for both the author and the person who wrote the comment?

Also, what is this code snippet you’ve attached? Is it your original working code for #1, or is it your skeleton for doing #2?

(I’m not sure whether or not I’ll need to know what these “Notification” objects are - if it’s part of a 3rd party package, it might help to specify which one. If not, we may need to see it as well.)


Thank you @KenWhitesell for replying. I have found answer to my question. The notification objects is not a 3rd party package and the code snippet attached is my working code
Yes, you are correct by the breakdown of my question. I found solution here: