Annotating a QuerySet within a FilterSet Class #1490
Unanswered
MichielDeKoninck
asked this question in
Q&A
Replies: 1 comment
-
Good news: explicitly creating a new queryset with annotation and then filtering on that, seems to solve the problem.
Solves the problem. |
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.
-
Hi everyone!
I am trying to use a FilterSet Class in support of a ViewSet to get the view that I need.
For this I would like to:
I want to do this annotation in the FilterSet because it is where I have the inputs (date range) readily available.
Question: Can I annotate on a QuerySet within a FilterSet?
I am unable to do the annotation and get the error below (error 1). FYI: I do not get this error if I make a dummy annotation on the same field directly in the ViewSet. And the field
num_week_specific_matches
has been declared as anIntegerField()
in the serializer_class of the Viewset.The Reduced Code:
The Error:
Got AttributeError when attempting to get a value for field
num_week_specific_matcheson serializer
AllRequestSerializer. The serializer field might be named incorrectly and not match any attribute or key on the
Requestinstance. Original exception text was: 'Request' object has no attribute 'num_week_specific_matches'.
Cannot resolve keyword 'num_week_specific_matches' into field. Choices are: city, country, created_at, customer, geopoint, house_number, id, is_deleted, last_updated_at, match, maximum_gfa, minimum_gfa, minimum_site_area, name, num_matches, num_selected_matches, owner, postal_code, radius, requested_destination, source, street
Will try to post a minimal working version ASAP.
Beta Was this translation helpful? Give feedback.
All reactions