[Answer]-Get value in a post request, Django

1👍

The data you are sending is simply a json string.

You have to parse that string before you can access data within it. For this you can use Python’s json module (it should be available if you’re using Python 2.7).

import json
data = json.loads( request.POST.get('id') )
id = data["id"]

If you somehow don’t have the json module, you can get the simplejson module.

For more details, refer this question : best way to deal with JSON in django

👤slider

0👍

That’s happening because id is string, not dict as it should be. Please provide your template and view code to find source of problem.

Leave a comment