An AssertionError occurred while trying to operate asynchronous view as class-based view in django(CBV)
The python code i wrote is as follows.
urls.py
from django.contrib import admin
from django.conf.urls import include
from django.urls import re_path
from rest_framework import routers
from blog import views
router = routers.DefaultRouter()
router.register(r'test', views.TestView, 'hello')
urlpatterns = [
re_path(r'^admin/', admin.site.urls),
re_path(r'', include(router.urls)),
re_path(r'async_view/', include(router.urls))
]
views.py
class TestView(viewsets.ViewSet):
LOG = logging.getLogger('test')
async def list(self, request, *args, **kwargs):
self.LOG.info("async method start!!")
queryset = Post.objects.none
await asyncio.sleep(3)
return HttpResponse("Hello async world!")
asgi.py
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_asgi_application()
When i execute command below
uvicorn mysite.asgi:application --limit-concurrency 12 --reload --host 0.0.0.0 --port 80
then, An AssertionError occurred
AssertionError: Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `<class 'coroutine'>`
Which part is wrong??