1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

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>
This commit is contained in:
Antoine Lorence
2022-09-29 12:10:02 +02:00
committed by Carlton Gibson
parent 19e6efa50b
commit 9b0c9821ed
3 changed files with 35 additions and 3 deletions

View File

@@ -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."""