File tree 1 file changed +9
-2
lines changed 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,13 @@ the ``null_label`` parameter. More details in the ``ChoiceFilter`` reference
142
142
queryset=Category.objects.all(),
143
143
)
144
144
145
+ Solution 3: Comining fields w/ ``MultiValueField``
146
+ """"""""""""""""""""""""""""""""""""""""""""""""""
147
+
148
+ An alternative approach is to use Django's ``MultiValueField`` to manually add
149
+ in a ``BooleanField`` to handle null values. Proof of concept:
150
+ https://github.com/carltongibson/django-filter/issues/446
151
+
145
152
146
153
Filtering by an empty string
147
154
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -153,7 +160,7 @@ interpreted as a skipped filter.
153
160
154
161
GET http://localhost/api/my-model?myfield=
155
162
156
- Solution 1: magic values
163
+ Solution 1: Magic values
157
164
""""""""""""""""""""""""
158
165
159
166
You can override the ``filter()`` method of a filter class to specifically check
@@ -176,7 +183,7 @@ for magic values. This is similar to the ``ChoiceFilter``'s null value handling.
176
183
return qs.distinct() if self.distinct else qs
177
184
178
185
179
- Solution 2: empty string filter
186
+ Solution 2: Empty string filter
180
187
"""""""""""""""""""""""""""""""
181
188
182
189
It would also be possible to create an empty value filter that exhibits the same
You can’t perform that action at this time.
0 commit comments