Replies: 1 comment
-
Use the .qs property to get the filtered queryset, then extract the .query.where if needed — but for annotations, a cleaner way is to build your own Q manually from the filter form:
Then:
NOTE:
Let me know if you want a reusable utility that supports nested field names or __in lookups. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using django-filter to filter down querysets.
Now, in another part of my code, I want to use the same filter set, but I won't want to filter a queryset -- instead, I want to filter an aggregation. Is is possible to get a Q-expression from django-filter?
For example, say I have
and now I want to use this as an annotation. Can I do something along the lines of
Beta Was this translation helpful? Give feedback.
All reactions