Opened 7 years ago

Closed 5 years ago

#28991 closed New feature (fixed)

Add an admin filter with choices "all", "blank", "not blank"

Reported by: Jonas Haag Owned by: Federico Jaramillo Martínez
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Add a new admin filter that allows to show only objects with a blank (or non-blank) field value. Shows three options "all", "blank", "not blank".

This is something I've regularly required and there doesn't seem to be any third party package implementing this, but there are at least a few other people having the need: https://stackoverflow.com/questions/37799694/django-admin-list-filter-filter-field-by-is-empty-none-or-empty-string https://gist.github.com/haplo/2695675 Note that while the filter could easily live in a third party package, I think it makes sense to include it in Django. It's not much code and I guess it's a common requirement.

Change History (14)

comment:2 by Tim Graham, 7 years ago

Duplicate of #28687?

comment:3 by Jonas Haag, 7 years ago

Not exactly here we're looking at

  • a new filter for
  • blank values
  • of any kind of field (not necessarily relation fields)

#28687 is looking at

  • an extension of an existing filter
  • of null values
  • that deals with relation fields
Version 0, edited 7 years ago by Jonas Haag (next)

comment:4 by Tim Graham, 7 years ago

Needs documentation: set
Summary: Add new BlankFieldListFilter admin filterAdd an admin filter with choices "all", "blank", "not blank"
Triage Stage: UnreviewedAccepted

comment:5 by Christophe Baldy, 6 years ago

Hi,

I tried to rework and improve the original PR with my own PR https://github.com/django/django/pull/10599

(This my first attempt to contribute to Django)

Thanks

Last edited 6 years ago by Christophe Baldy (previous) (diff)

comment:6 by Basil Dubyk, 6 years ago

Owner: changed from nobody to Basil Dubyk
Status: newassigned

comment:7 by Basil Dubyk, 6 years ago

Owner: Basil Dubyk removed
Status: assignednew

comment:8 by Simon Charette, 6 years ago

Needs documentation: unset
Patch needs improvement: set

Left a few comments for improvements on the PR.

comment:9 by Christophe Baldy, 6 years ago

Patch needs improvement: unset

comment:10 by Carlton Gibson, 6 years ago

Patch needs improvement: set

Commented on PR: Docs need some clarification. Possibly some extra tests needed. (?) Needs updating to target v3.0.

comment:11 by Federico Jaramillo Martínez, 5 years ago

Owner: set to Federico Jaramillo Martínez
Status: newassigned

comment:12 by Federico Jaramillo Martínez, 5 years ago

Patch needs improvement: unset

comment:13 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:14 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 372eaa39:

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

Thanks Simon Charette and Carlton Gibson for reviews.

Co-Authored-By: Jonas Haag <jonas@…>
Co-Authored-By: Christophe Baldy <christophe.baldy@…>

Note: See TracTickets for help on using tickets.
Back to Top