Opened 12 years ago
Last modified 12 years ago
#21564 closed Bug
Generic base view http_method_not_allowed method references self.request and should use locally scoped request — at Version 4
| Reported by: | Adam DePue | Owned by: | nobody |
|---|---|---|---|
| Component: | Generic views | Version: | 1.6 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The current method in django/views/generic/base.py is:
def http_method_not_allowed(self, request, *args, **kwargs):
logger.warning('Method Not Allowed (%s): %s', request.method, request.path,
extra={
'status_code': 405,
'request': self.request
}
)
return http.HttpResponseNotAllowed(self._allowed_methods())
The 'extra' dictionary should reference the locally scoped 'request' object instead of the class scoped member.
There is a PR open with this fix:
https://github.com/django/django/pull/2035
The side effect is that any unit test written that uses the view and manually calls the dispatch method to validate non-allowed-methods will crash with attribute not found error for request
Change History (4)
comment:1 by , 12 years ago
| Type: | Uncategorized → Bug |
|---|
comment:2 by , 12 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 12 years ago
comment:4 by , 12 years ago
| Description: | modified (diff) |
|---|---|
| Needs tests: | unset |
| Triage Stage: | Accepted → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
Test added to PR.