#32468 closed Bug (fixed)
Admin never_cache decorators needs method_decorator
Reported by: | hakib | Owned by: | hakib |
---|---|---|---|
Component: | contrib.admin | Version: | 3.1 |
Severity: | Normal | Keywords: | admin |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
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:
Change History (5)
comment:1 by , 4 years ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Thanks for the report.