-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Closes: #16837 - Add EmptyStringFilter and type__empty filter on CableFilterSet #17481
Conversation
Note -- the "Magic Values" solution in the django-filter docs might actually be a better solution here, because then we could add |
The |
I pushed a change that removes that check for However: we need to understand/communicate the difference in use cases here. Only query params where the key is exactly the same are OR'd together; all the rest are AND'ed (each is applied sequentially via a
And you will get BOTH
Then you won't get any results, because it's trying to AND two separate filter operations together ( The way I set up the |
Closing this PR in favor of #17574. Will open a new PR against a feature request for |
Fixes: #16837
Adds
EmptyStringFilter
from the django-filter documentation's common solutions: https://django-filter.readthedocs.io/en/main/guide/tips.html#filtering-by-an-empty-stringhttp://127.0.0.1:8000/dcim/cables/?type__empty=true
and=false
will now work as expected. Filter naming (type__empty
) is open to comments.This same filter can be added to any other filtersets as needed.
Note that this only adds the ability to filter directly via URL; it does not add the empty value to the filter form.