-
Notifications
You must be signed in to change notification settings - Fork 767
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
Search NULL values on all field types #639
Conversation
Few things to note:
I struggled a bit on making form validation work: see filterset.py, lines 222-227. Comments and suggestions are welcome :) |
I can provide more details, but I'm kind of -1 on these changes since it will play poorly with non-text inputs. My recommendation is to use a separate filter to handle null values explicitly, as demonstrated in the docs. An example of poor form usage would be number inputs. The html number input does not allow text entry, so it's not possible to submit the 'null' string. If you manually coerce the querystring to filter by the null string, then the form field will have to be altered to a text input. When re-rendering the form, the number controls will not be present. This also applies to date, datetime, and custom fields (such as any |
Indeed I agree they play poorly when it comes to use them in inputs, especially those generated automatically on DRF web interface for example. I think this also makes sense for choices filters ( Maybe |
Setting If I recall correctly, null-choice filtering was not added to |
|
True, and it would not be much effort to extend the existing functionality it to |
Codecov Report
@@ Coverage Diff @@
## develop #639 +/- ##
==========================================
Coverage ? 97.81%
==========================================
Files ? 15
Lines ? 1096
Branches ? 0
==========================================
Hits ? 1072
Misses ? 24
Partials ? 0
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to make a little time to review fully but in general I quite like this. (I like the idea and the implementation looks pretty light at first glance.)
I think we probably need to review the usage docs here. (There's already a good section on filtering for null values, it probably just needs expanding.)
Also, if you rebase this is Codecov happier? (There should be a base coverage report on develop
now.)
django_filters/filterset.py
Outdated
@@ -222,7 +226,7 @@ def form(self): | |||
fields = OrderedDict([ | |||
(name, filter_.field) | |||
for name, filter_ in six.iteritems(self.filters)]) | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you set your editor to trim trailing whitespace?
…tipleChoiceFilter and MultipleModelChoiceFilter.
No description provided.