Update docs/api-guide/views.md

Co-authored-by: Paolo Melchiorre <paolo@melchiorre.org>
This commit is contained in:
Enrico Massa 2022-09-05 01:16:16 +08:00 committed by GitHub
parent 7b18380321
commit 053eabf695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,13 +225,13 @@ For class based views, all handler methods must be async, otherwise Django will
For example:
class ListUsers(APIView):
class AsyncView(APIView):
async def get(self, request):
return Response({"message": "This is an async class based view."})
@api_view(['GET'])
async def view(request):
async def async_view(request):
return Response({"message": "This is an async function based view."})
[cite]: https://reinout.vanrees.org/weblog/2011/08/24/class-based-views-usage.html