1👍
✅
You are serializing the object into jsonObject
, but you return the original object
. Just fix that and everything should work as expected.
Update:
Just change your code like this:
jsonObject = serializers.serialize('json', object, fields=('value', 'record_time'))
return HttpResponse(jsonObject, mimetype="application/json")
The change is the jsonObject
in the second line.
0👍
Where you’re going wrong is confusing the printed representation of a JSON string with the actual string itself. Those slashes are just the console showing that the double-quotes inside the string are not ending the string, but are part of it. In other words, your JSON is just fine.
- [Answer]-Deploy django webserver on apache
- [Answer]-Django 2 different views in 2 different apps for same URL
- [Answer]-Dictionaries in django templates
- [Answer]-Freezing form URL in Django
Source:stackexchange.com