0

Hello I am using Post_save signal for sending a notification from the model ....

But I am getting an error like this "sending_notification() missing 1 required positional argument: 'request' "

@receiver(post_save, sender=Plan)
def sending_notification(request, sender, instance,created, **kwargs):
    if created:
        notify.send(request.user, recipient = request.user, verb = "Some messages")
Anoop
  • 505
  • 8
  • 23

1 Answers1

1

You cannot access request there, Remove request from signal params.

@receiver(post_save, sender=Plan)
def sending_notification(sender, instance, created, **kwargs):
    if created:
        pass

I see what you are trying to achieve here, you are using django-notifications-hq to send a notification to users, you can do this in the view itself as request won't be available in model signals.

https://stackoverflow.com/a/4716440/8105570

danish_wani
  • 862
  • 9
  • 14