#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()),
]
我明白了:
AttributeError at /testclass/
'coroutine' object has no attribute 'get'
##########
AttributeError at /testfunc/
'coroutine' object has no attribute 'get'