#22569: lookup_allowed fails to consider dynamic list_filter -----------------------------------------+-------------------- Reporter: Keryn Knight <django@…> | Owner: nobody Type: Uncategorized | Status: new Component: contrib.admin | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------------------+-------------------- 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 [https://github.com/django/django/search?q=lookup_allowed&ref=cmdform it's used infrequently] - the only place it's actually used is in [https://github.com/django/django/blob/274048351ae2fc35995645a6dad7c98f74f51eb1/django/contrib/admin/views/main.py#L96 ChangeList.get_filters], which has access to the request. However, it is overridden [https://sourcegraph.com/search?page=1&per_page=100&q=lookup_allowed in the wild] without accept `*args, **kwargs`, so it'd not be easy to provide a clean upgrade path. -- Ticket URL: <https://code.djangoproject.com/ticket/22569> 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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/080.6363f69d9232e31a7e444ab08eca2a94%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.