mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[4.1.x] Fixed #34062 -- Updated View.http_method_not_allowed() to support async.
As with the options() methods, wrap the response in a coroutine if
the view is async.
Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
Backport of 9b0c9821ed from main
This commit is contained in:
committed by
Carlton Gibson
parent
97353bc64b
commit
ecf6506f44
@@ -148,7 +148,16 @@ class View:
|
||||
request.path,
|
||||
extra={"status_code": 405, "request": request},
|
||||
)
|
||||
return HttpResponseNotAllowed(self._allowed_methods())
|
||||
response = HttpResponseNotAllowed(self._allowed_methods())
|
||||
|
||||
if self.view_is_async:
|
||||
|
||||
async def func():
|
||||
return response
|
||||
|
||||
return func()
|
||||
else:
|
||||
return response
|
||||
|
||||
def options(self, request, *args, **kwargs):
|
||||
"""Handle responding to requests for the OPTIONS HTTP verb."""
|
||||
|
||||
Reference in New Issue
Block a user