How do I use null_label and/or null_value in ChoiceFilter for empty values? #1592
Unanswered
CelestialGuru
asked this question in
Q&A
Replies: 1 comment
-
I should mention that in my case, |
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
-
The documentation mentions that
null_label
(andnull_value
?) can be used to allow filtering by none stuff as well as real stuff.https://django-filter.readthedocs.io/en/stable/guide/tips.html#solution-2-using-choicefilter-s-null-choice
https://django-filter.readthedocs.io/en/stable/ref/filters.html#choicefilter
#519 seems to be where this was added but I don't know exactly what it does nor how to use this feature. What I want to know is for
?{a}={b}
, what is meant to go fora
and what is meant to go inb
?With
this is what happens when I try to use it:
/api/products/?category=1
ValueError: The QuerySet value for an isnull lookup must be True or False.
/api/products/?category=Uncategorized
{"category":["Select a valid choice. That choice is not one of the available choices."]}
What am I missing here?
Beta Was this translation helpful? Give feedback.
All reactions