1
class HelloWorldView(APIView):

def post(self, request):
    print("request body....", request._request.body)
    print(f"drf data {request.data}")
    print("inside request type...", type(request._request))
    return HttpResponse("Hello world")

output

request body.... b'{"test": "body here"}'

drf data {}

inside request type... <class 'django.core.handlers.asgi.ASGIRequest'>

Issue

When i deploy application with asgi on server request.data is empty for post requests. It works fine in my local. The difference here noticed is that in local request._request is WSGIRequest while in server it is ASGIRequest. somehow DRF not able to convert the ASGIRequest's post data to request.data.

I am using Mangum to server requests (conneting api gateway--> lambda --> django rest) can somebody help me to fix this issue ?

Sandeep Balagopal
  • 1,943
  • 18
  • 28

0 Answers0