Replies: 1 comment 2 replies
-
Are you building the UI in JavaScript? In which case you could get the choices from the users field of the filter set form and serialise those to send across. Otherwise I'm still not quite sure what you mean: just use the Django form and it'll already have the right choices, would be the standard answer. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Recently, I stumbled across a behavior that looks wrong at first glance and that has already been mentioned in some issues and discussions.
On closer inspection, however, the behavior of Django Filter is absolutely correct.
About the “problem”:
I use the AllValuesMultipleFilter in one place to filter for the possible users.
This filter is used in a DRF ViewSet and consumed via API by a frontend.
In the frontend, a user filter is offered that is based on all active users.
If you now select a user that does not exist in the queryset to be filtered, DjangoFilter throws a 404.
Superficially, this should return a 200 with an empty result, but this is not correct because a user was searched for who does not appear in the AllValuesMultiple result. Ergo, 404 is correct.
Now to my question:
Is it possible to somehow get the results returned by AllValuesMultipleFilter into the view?
Then the respective frontend could simply use this data as the basis for the filter options, there would no longer be a 404 and the query would be correct in itself.
I hope this summarizes the problem clearly.
Beta Was this translation helpful? Give feedback.
All reactions