Opened 8 months ago

Last modified 8 months ago

#29232 new New feature

Add title option for admin filter when providing a field name

Reported by: David Sanders Owned by: nobody
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

The generated title for admin filters when the field is on a related model is often times confusing and not usable since it will be the name of the field without any reference to the fact that it's on a related model instead of the main model. When the field has the same name as a field on the main model it appears as a duplicate as far as the user can tell.

This patch expands the existing tuple pattern for a list_filter item to allow the second parameter to be a string which will be used as the title, instead of only allowing a class inheriting from FieldListFilter. This dove-tails nicely with the existing functionality as providing a subclass of FieldListFilter allows you to easily provide a title on the class itself, but the ability to provide just a string to use as a title removes the need to subclass the correct class choice for the field type (which is fragile) and streamlines the process for when you only want to change the title.

Change History (2)

comment:1 Changed 8 months ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:2 Changed 8 months ago by Carlton Gibson

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top