I need to get the raw content of POST request body (as a string) yet when I try to access request.body
I\'m getting an exception:
django.http.request
I might be missing something here but I'm pretty sure you don't need to define a custom parser in this case...
You can just use the JSONParser from DRF itself:
from rest_framework.decorators import api_view
from rest_framework.decorators import parser_classes
from rest_framework.parsers import JSONParser
@api_view(['POST'])
@parser_classes((JSONParser,))
def example_view(request, format=None):
"""
A view that can accept POST requests with JSON content.
"""
return Response({'received data': request.data})