[Django] #33575: 'process_template_response' middleware hook can not be a static method, but documentation suggests otherwise

4 views
Skip to first unread message

Django

unread,
Mar 14, 2022, 7:33:51 AM3/14/22
to django-...@googlegroups.com
#33575: 'process_template_response' middleware hook can not be a static method, but
documentation suggests otherwise
-------------------------------------+-------------------------------------
Reporter: Eugene | Owner: nobody
Vihrev |
Type: Bug | Status: new
Component: Core | Version: 4.0
(Other) | Keywords: middleware,
Severity: Normal | documentation
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
In documentation page on other middleware hooks
(https://docs.djangoproject.com/en/4.0/topics/http/middleware/#process-
template-response) signature of {{{process_template_response}}} method
does not have {{{self}}} among its arguments, suggesting it is not
required, so the method can be marked as static. Doing so results in non-
verbose error occurring in
[https://github.com/django/django/blob/4.0.2/django/core/handlers/base.py#L256
| django/core/handlers/base.py on line 256] due to how django gets
middleware name from {{{middleware_method}}}
({{{middleware_method.__self__.__class__.__name__}}}).

I think that documentation should have {{{self}}} in the method signature
and user should get a verbose message that {{{@staticmethod}}} is not
allowed. Or maybe this behaviour should be changed so all middleware hook
methods could be static.

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

Reply all
Reply to author
Forward
0 new messages