Opened 9 years ago

Closed 9 years ago

#24256 closed New feature (needsinfo)

No easy way to access the filtered queryset from admin.SimpleListFilter

Reported by: Tomas Babej Owned by: nobody
Component: contrib.admin Version: 1.7
Severity: Normal Keywords:
Cc: Tomas Babej Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a simple goal - I want to build a admin.SimpleListFilter, which offers in the lookups method only those choices which are relevant to the current user selection.

The lookups() method gets passed the ModelAdmin instance via model_admin argument, however, calling

queryset = model_admin.get_queryset()

will return only the unfiltered queryset. There is no easy way how to get the filtered queryset, since that is defined in the ChangeView class, one is only left to duplicate much of the logic of that class to get the filtered queryset.

Change History (3)

comment:1 by Tomas Babej, 9 years ago

Component: Uncategorizedcontrib.admin

comment:2 by Tomas Babej, 9 years ago

Cc: Tomas Babej added

comment:3 by Tim Graham, 9 years ago

Resolution: needsinfo
Status: newclosed

Absent a specific proposal for how to make this possible, I don't see much value in accepting the ticket. Please reopen if you have ideas to share or want to try implementing something.

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