mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 00:19:53 +03:00
Fix for missing await and using getattr instead of hasattr
This commit is contained in:
parent
c6cf2d7e83
commit
ec1d7547fd
|
@ -525,7 +525,7 @@ class APIView(View):
|
||||||
self.headers = self.default_response_headers # deprecate?
|
self.headers = self.default_response_headers # deprecate?
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sync_to_async(self.initial)(request, *args, **kwargs)
|
await sync_to_async(self.initial)(request, *args, **kwargs)
|
||||||
|
|
||||||
# Get the appropriate handler method
|
# Get the appropriate handler method
|
||||||
if request.method.lower() in self.http_method_names:
|
if request.method.lower() in self.http_method_names:
|
||||||
|
@ -547,7 +547,7 @@ class APIView(View):
|
||||||
Dispatch checks if the view is async or not and uses the respective
|
Dispatch checks if the view is async or not and uses the respective
|
||||||
async or sync dispatch method.
|
async or sync dispatch method.
|
||||||
"""
|
"""
|
||||||
if hasattr(self, 'view_is_async') and self.view_is_async:
|
if getattr(self, 'view_is_async', False):
|
||||||
return self.async_dispatch(request, *args, **kwargs)
|
return self.async_dispatch(request, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
return self.sync_dispatch(request, *args, **kwargs)
|
return self.sync_dispatch(request, *args, **kwargs)
|
||||||
|
@ -562,7 +562,7 @@ class APIView(View):
|
||||||
data = self.metadata_class().determine_metadata(request, self)
|
data = self.metadata_class().determine_metadata(request, self)
|
||||||
return Response(data, status=status.HTTP_200_OK)
|
return Response(data, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
if hasattr(self, 'view_is_async') and self.view_is_async:
|
if getattr(self, 'view_is_async', False):
|
||||||
async def handler():
|
async def handler():
|
||||||
return func()
|
return func()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user