revsys/django-friendship

Issue in Singal friendship_request_canceled

Closed this issue · 1 comments

When the user cancels the request signal send after that, it causes to not send user instance, at the receiver point
and it show

2020-09-26 (2)

Error = raise TypeError("Model instances without primary key value are unhashable")

fix is simple :
1 open models.py

2 search friendship_request_canceled

3 then find this code

   def cancel(self):
        """ cancel this friendship request """
        self.delete()
        friendship_request_canceled.send(sender=self)
        bust_cache("requests", self.to_user.pk)
        bust_cache("sent_requests", self.from_user.pk)
        return True

4 Replace with

def cancel(self):
        """ cancel this friendship request """
        friendship_request_canceled.send(sender=self)
        self.delete()
        bust_cache("requests", self.to_user.pk)
        bust_cache("sent_requests", self.from_user.pk)
        return True

This Solution may help lot of New Django-friendship Users


Thanks someone else also reported this and I just fixed it before seeing yours is all. Thanks!