Search code examples
djangodjango-channels

Send notification on post_save signal in django


I have a model called deposit and I am trying to send real time notification when a new row is added in table. Is it possible to do so using django-channels ?


Solution

  • You can simply add a signal for a post_save

    @receiver(post_save, sender=Deposit)
    def signal_deposit_save(sender, instance, created, **kwargs):
        if created: # This means it is a new row
            # Send notification using django-channels