Opened 11 months ago

Last modified 2 weeks ago

#28991 new New feature

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

Reported by: Jonas Haag Owned by:
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
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 (8)

comment:2 Changed 11 months ago by Tim Graham

Duplicate of #28687?

comment:3 Changed 11 months ago by Jonas Haag

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
Last edited 11 months ago by Jonas Haag (previous) (diff)

comment:4 Changed 11 months ago by Tim Graham

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

comment:5 Changed 5 weeks ago by Christophe Baldy

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 5 weeks ago by Christophe Baldy (previous) (diff)

comment:6 Changed 5 weeks ago by Basil Dubyk

Owner: changed from nobody to Basil Dubyk
Status: newassigned

comment:7 Changed 5 weeks ago by Basil Dubyk

Owner: Basil Dubyk deleted
Status: assignednew

comment:8 Changed 2 weeks ago by Simon Charette

Needs documentation: unset
Patch needs improvement: set

Left a few comments for improvements on the PR.

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