0
#views.py

async def test(request: ASGIRequest):
    return HttpResponse(b'hello')

class Test(View):
    async def get(self, request: ASGIRequest):
        print(type(request))
        print(dir(self))
        return HttpResponse(b'hello')
#urls.py

urlpatterns = [
    path('admin/', admin.site.urls),
    path(r'testfunc/', test),
    path(r'testclass/', Test.as_view()),
]

I get this:

AttributeError at /testclass/
'coroutine' object has no attribute 'get'

##########

AttributeError at /testfunc/
'coroutine' object has no attribute 'get'
briancaffey
  • 2,339
  • 6
  • 34
  • 62
Cajio
  • 11
  • 1
  • 3

2 Answers2

0

In django 3.0, they started adding django support but this does not mean that we can use async views or middlewares.

Read more about it here: https://docs.djangoproject.com/en/3.0/topics/async/

Glyphack
  • 876
  • 9
  • 20
0

Django 3.0 was the first step towards making it fully async-capable, but it will be a long journey. Async views are not yet supported, but they are expected later in the 3.x series.

Dauros
  • 9,294
  • 2
  • 20
  • 28