AllValuesMultipleFilter raises 404 error if any option does not exist #1420
Replies: 4 comments 3 replies
-
Sounds as if you’re filtering to an empty QuerySet, and so DRF is (as expected) raising a 404 error? 🤔 |
Beta Was this translation helpful? Give feedback.
-
The problem is, for example, if I select the filter age Maybe there is a way to solve this, but, unfortunately, I wasn't able to find it. Thank you so much for your reply. |
Beta Was this translation helpful? Give feedback.
-
I stumbled about this today and had the same thought (404 or empty list). I think the 404 is correct here, as we are referring to data which is not in the pre-filtered list. |
Beta Was this translation helpful? Give feedback.
-
In my case, the frontend is using data from an endpoint with all active user(ids). A look into the browsable API shows that we have a correct list with all possible and valid values. Question: Is there a way to get the pre-filtered data into the view? Then the frontend could simply use this. I guess it's possible to do some magic with accessing the filterset_class, but is there a recommend way? |
Beta Was this translation helpful? Give feedback.
-
I have a search feature with on multiple fields (age, gender, location, etc.) and I'm using
AllValuesMultipleFilter
withlookup_expr
contains
to do the searches. The options among each field are acting like an OR, but among different fields, it is an AND, as expected.My current problem is when I trigger a search and I pick a value (ex. age 12-20) which is NOT in any entity, instead of ignoring it and returning either nothing or the other matches (ex. if I also choose gender female, all entities where gender is female) I am getting a 404 error and my app is going to the 404 page.
Is there any way to solve this? Or should this be reported as a bug?
Profile filter set:
Serializer:
Model:
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions