#17789: when i use a custom FieldListFilter class for a given field.
---------------------------------+--------------------------------------
Reporter: Kidwind | Owner: julien
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.4
Severity: Normal | Resolution: needsinfo
Keywords: FieldListFilter | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by KyleMac):
My issue is that I wanted to use custom filters to change the titles of
filters to clarify their purpose. However you can't do this with filters
that span relationships because of the subject of this ticket.
There is currently no other way to change the title of a filter other than
using `verbose_name` on the field itself but that has a much wider effect.
What I was trying to do was something like the following:
{{{
class PastSupplierFilter(RelatedFieldListFilter):
def __init__(self, *args, **kwargs):
super(PastSupplierFilter, self).__init__(*args, **kwargs)
self.title = _('past supplier')
class ReorderAdmin(admin.ModelAdmin):
list_filter = (
('product__suppliers', PastSupplierFilter),
)
}}}
A better solution but a more complex change would be to allow
`list_filter` to accept a third value as the title of the filter. Django
currently assumes that the name of a field and the purpose/effect of a
filter are the same, which is not always the case especially when spanning
relationships.
--
Ticket URL: <https://code.djangoproject.com/ticket/17789#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.