Use JsonResponse instead of HttpResponse when attempting to send JSON data.
Non-Compliant Code Examples
importjsonfromdjango.httpimportHttpResponseresponse_data={}response_data['result']='error'response_data['message']='Some error message'returnHttpResponse(json.dumps(response_data))# use a JsonResponse to send JSON data