-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filtering on action_object: Field 'action_object' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. #281
Comments
please post the python code you are using and the full traceback of the error |
I succeeded a bit with adding the GenericRelation and querying based on the I'll create a test project to showcase this problem. |
Here you are: https://github.com/graup/django-activity-stream-test This also happens to reproduce #278. |
@graup very helpful test project! been playing with it and in doing so i noticed a bug that is related to some other issues. unfortunately fixing it did not resolve this issue. This is the approach that makes the most sense to me but is still far away from working: # Version 1: Fails because of missing reverse relation
filters = {'action_object__read': False, 'action_object__deleted': False} This is the solution that makes the least sense to me but is the closest to working: # Version 2: Fails because of not matching db column types
filters = {'notification__read': False, 'notification__deleted': False} This is the query that is being performed in version 2: SELECT "actstream_action"."id",
"actstream_action"."actor_content_type_id",
"actstream_action"."actor_object_id",
"actstream_action"."verb",
"actstream_action"."description",
"actstream_action"."target_content_type_id",
"actstream_action"."target_object_id",
"actstream_action"."action_object_content_type_id",
"actstream_action"."action_object_object_id",
"actstream_action"."timestamp",
"actstream_action"."public"
FROM "actstream_action"
INNER JOIN "example_notification"
ON ( "actstream_action"."action_object_object_id" =
"example_notification"."id"
AND ( "actstream_action"."action_object_content_type_id" = 9
) )
WHERE ( "actstream_action"."actor_object_id" = 1
AND "actstream_action"."actor_content_type_id" = 4
AND "example_notification"."deleted" = false
AND "example_notification"."read" = false )
ORDER BY "actstream_action"."timestamp" DESC Ive been trying to get a CAST stmt setup on the INNER JOIN to make the types comparable. In django you can use the Unfortunately these joins on generic relations can get a bit messy. Im going to play around with it some more and hopefully get the approach that makes the most sense working in the best way. |
Similar issue here. |
Hi! I used your example from django-notifications/django-notifications#64 (comment) to add a Notification model that is saved as the
action_object
.However, when in the stream I try to
return sender.actor_actions.filter('action_object__read': False)
(sender
ist the current user), Django fails withField 'action_object' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.
I don't really understand this error, because I am not actually querying in reverse here, am I?
Any ideas?
The text was updated successfully, but these errors were encountered: