I am creating a nested dict in javascript and then send it with an Ajax call to one of my Django methods.
The dict is created like this:
var dictData = {};
$('#selector').each(function() {
assistance1Data[$(this).attr('id')] = parseInt($(this).val());
});
var formData = {};
formData["name"] = name;
formData["task_id"] = task_id;
formData["description"] = $("#description").val();
formData["nestedDict"] = dictData;
$.ajax({
type : 'POST',
url : '/taskmanagement/changeName/',
dataType : 'html',
data: formData,
success : function(data){
return true;
}
});
This all works fine until here. And it also works fine inside the views.py function using, for example, request.POST["name"]. I need to access the dict though, but as soon as I get the queryDict, it looks something like this:
<QueryDict: {u'description': [u'desc'], u'task_id': [u'1'], u'inCharge': [u'1'], u'nestedDict[valueFromDictData_1]': [u'2'], u'nestedDict[valueFromDictData_0]': [u'1'], u'name': [u'someName']}>
What I would need would be something like key1: [key2_1: 1, key2_2: 2]
as dicts are usually structured instread of 'key1[key2_1']: 1 which makes the whole thing completely useless.