Opened 14 years ago
Closed 14 years ago
#15960 closed New feature (fixed)
Allow SimpleListerFilter's lookups to be based on the available data
Reported by: | Julien Phalip | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.3 |
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
Shortly after SimpleListFilter
landed in [16144], there were talks on IRC with jezdez, carljm and apollo13 about allowing filter lookups to be based on the available data. Taking the DecadeBornListFilter
example from the doc (http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter), you might want to only display the lookups for the decades where people were actually born in. This requires the lookups()
method to have access to the ModelAdmin
's queryset, somehow.
I'm attaching a patch with a suggested implementation.
Attachments (2)
Change History (5)
by , 14 years ago
Attachment: | 15960.simplelistfilter-queryset-based-lookups.diff added |
---|
comment:1 by , 14 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 14 years ago
Attachment: | 15960.simplelistfilter-queryset-based-lookups.2.diff added |
---|
This looks pretty reasonable and useful to me, as far as the API addition goes. Couple minor typos in the docs portion of the patch: "ModelAdmin objects" where it should be "ModelAdmin object", and one case of books_90s that should be born_in_90s.