[Django] #22569: lookup_allowed fails to consider dynamic list_filter

15 views
Skip to first unread message

Django

unread,
May 3, 2014, 12:01:24 PM5/3/14
to django-...@googlegroups.com
#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.

Django

unread,
May 5, 2014, 8:15:37 AM5/5/14
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: nobody
<django@…> | Status: new
Type: Bug | Version: master
Component: contrib.admin | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_docs: => 0
* needs_better_patch: => 0
* type: Uncategorized => Bug
* needs_tests: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:1>

Django

unread,
Nov 23, 2014, 4:20:49 PM11/23/14
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
<django@…> | parasgithub
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by parasgithub):

* status: new => assigned
* owner: nobody => parasgithub


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:2>

Django

unread,
Dec 31, 2015, 8:07:17 AM12/31/15
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
<django@…> | parasgithub
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by ernestoalejo):

* cc: contact@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:3>

Django

unread,
Aug 6, 2017, 10:41:56 PM8/6/17
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Simon
<django@…> | Meers
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Meers):

* owner: nobody => Simon Meers


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:4>

Django

unread,
Aug 6, 2017, 11:06:12 PM8/6/17
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Simon
<django@…> | Meers
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Meers):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/8856

--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:5>

Django

unread,
Aug 7, 2017, 6:50:54 PM8/7/17
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Simon
<django@…> | Meers
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:6>

Django

unread,
Aug 14, 2017, 8:05:59 AM8/14/17
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Simon
<django@…> | Meers
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Meers):

* needs_better_patch: 1 => 0


Comment:

I've now got three separate commits for the three tickets involved, and
three pull requests, though perhaps only this
https://github.com/django/django/pull/8904 pull request is needed since it
contains all three commits?

--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:7>

Django

unread,
Nov 23, 2021, 6:40:04 AM11/23/21
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: (none)
<django@…> |
Type: Bug | Status: new
Component: contrib.admin | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: Simon Meers => (none)
* status: assigned => new

Django

unread,
Mar 16, 2023, 5:42:56 AM3/16/23
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: (none)
<django@…> |
Type: Bug | Status: new
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Sarah Boyce (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:8>

Django

unread,
Apr 13, 2023, 5:50:02 AM4/13/23
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Sarah
<django@…> | Boyce
Type: Bug | Status: assigned

Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* owner: (none) => Sarah Boyce


* needs_better_patch: 1 => 0

* status: new => assigned


Comment:

https://github.com/django/django/pull/16759

--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:9>

Django

unread,
Apr 17, 2023, 2:43:00 AM4/17/23
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Sarah
<django@…> | Boyce
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:10>

Django

unread,
Apr 17, 2023, 4:51:34 AM4/17/23
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Sarah
<django@…> | Boyce
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:11>

Django

unread,
Apr 17, 2023, 8:08:16 AM4/17/23
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Sarah
<django@…> | Boyce
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:12>

Django

unread,
Apr 17, 2023, 8:39:52 AM4/17/23
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Sarah
<django@…> | Boyce
Type: Bug | Status: closed
Component: contrib.admin | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"594fcc2b7427f7baf2cf1a2d7cd2be61467df0c3" 594fcc2]:
{{{
#!CommitTicketReference repository=""
revision="594fcc2b7427f7baf2cf1a2d7cd2be61467df0c3"
Fixed #22569 -- Made ModelAdmin.lookup_allowed() respect
get_list_filter().

Thank you Simon Meers for the initial patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:13>

Django

unread,
Jan 15, 2025, 4:28:48 PMJan 15
to django-...@googlegroups.com
#22569: lookup_allowed fails to consider dynamic list_filter
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner: Sarah
<django@…> | Boyce
Type: Bug | Status: closed
Component: contrib.admin | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"8081557508b197af975e0c6306d9b2af5e57d477" 8081557]:
{{{#!CommitTicketReference repository=""
revision="8081557508b197af975e0c6306d9b2af5e57d477"
Refs #22569 -- Made request required in ModelAdmin.lookup_allowed() per
deprecation timeline.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22569#comment:14>
Reply all
Reply to author
Forward
0 new messages