Opened 16 months ago

Last modified 9 months ago

#22569 assigned Bug

lookup_allowed fails to consider dynamic list_filter

Reported by: Keryn Knight <django@…> Owned by: parasgithub
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, lookup_allowed iterates over self.list_filter to determine valid params. This is technically incorrect since the introduction of get_list_filter() on ModelAdmin in 1.5, because it is possible to define a ModelAdmin such that self.list_filter is () but get_list_filter yields SimpleListFilter classes.

To correct it, the above code would need to change from:

for filter_item in self.list_filter:

to

for filter_item in self.get_list_filter(request):

The problem is that now lookup_allowed needs to accept request so that it can pass it back to get_list_filter

In Django itself, that's actually reasonably acceptable as a change, because it's used infrequently - the only place it's actually used is in ChangeList.get_filters, which has access to the request. However, it is overridden in the wild without accept *args, **kwargs, so it'd not be easy to provide a clean upgrade path.

Change History (2)

comment:1 Changed 16 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

comment:2 Changed 9 months ago by parasgithub

  • Owner changed from nobody to parasgithub
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.
Back to Top