Fixed #28991 -- Added EmptyFieldListFilter class in admin.filters.

Thanks Simon Charette and Carlton Gibson for reviews.

Co-Authored-By: Jonas Haag <jonas@lophus.org>
Co-Authored-By: Christophe Baldy <christophe.baldy@polyconseil.fr>
This commit is contained in:
Federico Jaramillo Martínez 2018-01-05 23:53:51 +01:00 committed by Mariusz Felisiak
parent 03f6159407
commit 372eaa395f
5 changed files with 167 additions and 6 deletions

View file

@ -971,11 +971,24 @@ subclass::
limit the ``list_filter`` choices to the users who have written a book
instead of listing all users.
You can filter empty values using ``EmptyFieldListFilter``, which can
filter on both empty strings and nulls, depending on what the field
allows to store::
class BookAdmin(admin.ModelAdmin):
list_filter = (
('title', admin.EmptyFieldListFilter),
)
.. note::
The ``FieldListFilter`` API is considered internal and might be
changed.
.. versionadded:: 3.1
The ``EmptyFieldListFilter`` class was added.
List filter's typically appear only if the filter has more than one choice.
A filter's ``has_output()`` method controls whether or not it appears.