summaryrefslogtreecommitdiff
path: root/django/views/generic/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/views/generic/base.py')
-rw-r--r--django/views/generic/base.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/views/generic/base.py b/django/views/generic/base.py
index 3a3afb0c73..8f8f9397e8 100644
--- a/django/views/generic/base.py
+++ b/django/views/generic/base.py
@@ -1,6 +1,7 @@
-import asyncio
import logging
+from asgiref.sync import iscoroutinefunction, markcoroutinefunction
+
from django.core.exceptions import ImproperlyConfigured
from django.http import (
HttpResponse,
@@ -68,8 +69,8 @@ class View:
]
if not handlers:
return False
- is_async = asyncio.iscoroutinefunction(handlers[0])
- if not all(asyncio.iscoroutinefunction(h) == is_async for h in handlers[1:]):
+ is_async = iscoroutinefunction(handlers[0])
+ if not all(iscoroutinefunction(h) == is_async for h in handlers[1:]):
raise ImproperlyConfigured(
f"{cls.__qualname__} HTTP handlers must either be all sync or all "
"async."
@@ -117,7 +118,7 @@ class View:
# Mark the callback if the view class is async.
if cls.view_is_async:
- view._is_coroutine = asyncio.coroutines._is_coroutine
+ markcoroutinefunction(view)
return view