When you are using rest_framework you shouldn't use json.dumps
yourself, since the renderers do this work for you. The data you see is the python dictionary, which is the output of the serializer. It does not get rendered by DRF, because you are are returning a Django StreamingHttpResponse
. This data needs to be rendered to get your JSON.
Is there a reason for you bypassing the rest_framework rendering?
Otherwise, this is your Handler:
return Response(InstallSerializer(Install.objects.all(), many=True).data)
Where Response
is rest_framework.response.Response
.
If your client needs pretty json: The rest_framework JSONRenderer
supports the indent
argument for the Accept
header (see the docs).
So when your client sends:
Accept: application/json; indent=4
Your JSON will be indented.