[Django]-Handling ajax json object in Django – 'QueryDict' object has no attribute 'read' error

4👍

✅

request.POST is for form-encoded content. For JSON, you should access the plain body directly:

json_object = json.loads(request.body)

4👍

Why do you convert json_obj into string when sending it to server? I think you should do it in this way:

json_obj = {"key1": "value1", "key2": "value2"}
$.post('/update_vendor_merchandise_types/', json_obj)  

In this case on the server side you can access sent data in this way:

v1 = request.POST["key1"]

Leave a comment