我只想创建以下Json输出作为HttpResponse:
{ "status": "OK", "verified": true }
但出于某种原因不断出现错误。
答案 0 :(得分:-1)
想出来。我这样做了:
results= [{"status": "INVALID_REQUEST", "verified": False}]
return HttpResponse(simplejson.dumps(results), mimetype='application/json')
为什么这也会起作用?
results= [{"status": "INVALID_REQUEST", "verified": False}]
output = serializers.serialize('json', results, indent=2)
return HttpResponse(output, mimetype='application/json')