[Django] #32468: Admin never_cache decorators needs method_decorator

10 views
Skip to first unread message

Django

unread,
Feb 21, 2021, 8:19:09 AM2/21/21
to django-...@googlegroups.com
#32468: Admin never_cache decorators needs method_decorator
-----------------------------------------+------------------------
Reporter: hakib | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.1
Severity: Normal | Keywords: admin
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The login and logout views in Django's admin site are using the
`never_cache` decorator, but they are both instance methods, so they need
to use the method_decorator.

This is not a bug because the `never_cache` decorator is only operating on
the response. The first argument to the decorator is supposed to be the
request, but it is in-fact the admin_site instance (`self`). All the
arguments are then passed to the view function and the decorator operate
on the response.

If you try to use a different decorator that uses the request (such as
`required_http_methods`) you will fail.

AttributeError: 'CustomAdminSite' object has no attribute 'method'

Related issue from long time ago:

https://code.djangoproject.com/ticket/18923

--
Ticket URL: <https://code.djangoproject.com/ticket/32468>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 22, 2021, 1:14:40 AM2/22/21
to django-...@googlegroups.com
#32468: Admin never_cache decorators needs method_decorator
-------------------------------+------------------------------------

Reporter: hakib | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Thanks for the report.

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

Django

unread,
Feb 23, 2021, 4:05:43 AM2/23/21
to django-...@googlegroups.com
#32468: Admin never_cache decorators needs method_decorator
-------------------------------+------------------------------------
Reporter: hakib | Owner: hakib
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1

Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => hakib
* status: new => assigned
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/14030 PR]

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

Django

unread,
Feb 24, 2021, 3:41:08 AM2/24/21
to django-...@googlegroups.com
#32468: Admin never_cache decorators needs method_decorator
-------------------------------------+-------------------------------------

Reporter: hakib | Owner: hakib
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


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

Django

unread,
Feb 24, 2021, 5:09:09 AM2/24/21
to django-...@googlegroups.com
#32468: Admin never_cache decorators needs method_decorator
-------------------------------------+-------------------------------------
Reporter: hakib | Owner: hakib
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"3fd82a62415e748002435e7bad06b5017507777c" 3fd82a62]:
{{{
#!CommitTicketReference repository=""
revision="3fd82a62415e748002435e7bad06b5017507777c"
Refs #32468 -- Added error message on invalid usage of cache decorators.
}}}

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

Django

unread,
Feb 24, 2021, 5:09:10 AM2/24/21
to django-...@googlegroups.com
#32468: Admin never_cache decorators needs method_decorator
-------------------------------------+-------------------------------------
Reporter: hakib | Owner: hakib
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.1

Severity: Normal | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"63bbfa9f4501425f4bdabe05a79132a22dfbeb5a" 63bbfa9f]:
{{{
#!CommitTicketReference repository=""
revision="63bbfa9f4501425f4bdabe05a79132a22dfbeb5a"
Fixed #32468 -- Corrected usage of never_cache in contrib.admin.
}}}

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

Reply all
Reply to author
Forward
0 new messages