justquick / django-activity-stream

Generate generic activity streams from the actions on your site. Users can follow any actors' activities for personalized streams.

Home Page:http://django-activity-stream.rtfd.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Field 'actor' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.

tamhv opened this issue · comments

Hi everyone, i'm playing with django-activity-stream docs Custom Action Data https://django-activity-stream.readthedocs.io/en/latest/data.html and i found an issue, i seem can't query Action like the docs describe.

env

Django==3.2.9
django-activity-stream==1.4.2

setup

    def ready(self):
        from actstream import registry
        registry.register(apps.get_model(settings.AUTH_USER_MODEL))

django shell

In [9]: action.send(u,verb='started testing activity')
Out[9]: [(<function actstream.actions.action_handler(verb, **kwargs)>,
  <Action: system.admin started testing activity 0 minutes ago>)]
...
In [15]: user_stream(u, with_user_activity=True)
Out [15]: <GFKQuerySet [<Action: system.admin started testing activity 2 minutes ago>]>
...
In [47]: Action.objects.get(actor=u)
ERROR...
FieldError: Field 'actor' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.


where you are suggesting to use GenericRelation? can you elaborate more please?

did you register your user model for use with actstream?

i just set up a small demo to try it again here https://github.com/tamhv/dasdemo
still no luck

@auvipy i just want to make sure i've done full settings of django-activity-stream for my project, i copied and run a query from django-activity-stream documentation, section Custom Action Data, it showed the above error.

action = Action.objects.get(verb='answered', actor=galahad, target=bridgekeeper)
action.data['favorite_color']
'Blue. No, yel... AAAAAAA'
action.data['quest'] = 'To seek the Holy Grail'
action.save()
action.data
{'favorite_color': 'Blue. No, Green - AAAAAAA', 'quest': 'To seek the Holy Grail'}

@justquick yes i did, i can do action.send and query user_stream without issues, i tried to use registry.check to check it.

Any update on this? I'm trying to follow the example. I've verified that setup_generic_relations gets called on the User model, but actions = Action.objects.filter(actor=user) does not work.

Field 'actor' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.