#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.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.ccb928fdd04021bb9045d6b21d9db5a0%40djangoproject.com.

Reply via email to