v1k45 / django-notify-x

Notification system for Django
MIT License
187 stars 40 forks source link

Error when passing an AnonymousUser in an Actor #41

Closed rajat404 closed 7 years ago

rajat404 commented 7 years ago

In notify.send method, I passed actor=AnonymousUser This resulted in the following error:

TypeError: 'actor_content_object' is an invalid keyword argument for this function

Please suggest, what I might be doing wrong.

Complete Traceback:

~/project_path/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py in send(self, sender, **named)
    189
    190         for receiver in self._live_receivers(sender):
--> 191             response = receiver(signal=self, sender=sender, **named)
    192             responses.append((receiver, response))
    193         return responses

~/project_path/venv/lib/python3.6/site-packages/notify/signals.py in notifier(sender, **kwargs)
     83                 obj_url_text=obj_url,
     84
---> 85                 extra=extra
     86             ))
     87         saved_notification = Notification.objects.bulk_create(notifications)

~/project_path/venv/lib/python3.6/site-packages/django/db/models/base.py in __init__(self, *args, **kwargs)
    553                     pass
    554             if kwargs:
--> 555                 raise TypeError("'%s' is an invalid keyword argument for this function" % list(kwargs)[0])
    556         super(Model, self).__init__()
    557         signals.post_init.send(sender=self.__class__, instance=self)

TypeError: 'actor_content_object' is an invalid keyword argument for this function
v1k45 commented 7 years ago

Hi @rajat404, which version of django are you using? Does the actor keyword argument work with other arguments than AnonymousUser objects?

Also, django's AnonymousUser is not a database object, it is just an instance of class with API similar to actual user object. On top of that, you seem to be passing AnonymousUser class as an argument which inherently is wrong way of doing it.

rajat404 commented 7 years ago

Hi @v1k45 I'm using Django==1.10.5. actor keyword does work with other arguments.

According to the documentation all parameters can have Anonymous objects, so I assumed that it referred to django's AnonymousUser. Can you tell me exactly what kind of Anonymous objects can be used as arguments for actor

v1k45 commented 7 years ago

I think I have phrased it incorrectly. By anonymous objects I didn't mean that it allows objects without database reference, I meant that an actor can be anonymous conceptually and not programmatically.

If you don't have a database reference of your actor, just don't pass anything to that keyword argument. Maybe send an actor_text value instead.

v1k45 commented 7 years ago

Closing due to inactivity. Feel free to open it again.