У меня на сайте формируется массив с графиком работы через скрипт JS + JQuery:
var graph = [{"start":"","end":"","lunch_start":"","lunch_end":""},
{"start":"","end":"","lunch_start":"","lunch_end":""},
{"start":"","end":"","lunch_start":"","lunch_end":""},
{"start":"","end":"","lunch_start":"","lunch_end":""},
{"start":"","end":"","lunch_start":"","lunch_end":""},
{"start":"","end":"","lunch_start":"","lunch_end":""},
{"start":"","end":"","lunch_start":"","lunch_end":""}];
for(var i = 0; i < 7; i++) {
graph[i]["start"] = $('[id=timepick_start][day = '+i+']').val();
graph[i]["end"] = $('[id=timepick_end][day = '+i+']').val();
if ($('#is_launch[day = '+i+']').is(':checked')) {
graph[i]["lunch_start"] = $('[id=lunch_start][day = '+i+']').val();
graph[i]["lunch_end"] = $('[id=lunch_end][day = '+i+']').val();
}
}
Отправляется объект graphs через ajax запрос на сервер.
Приходит следующая штука:
<QueryDict: {'json_worktime[0][start]': [''], 'json_worktime[0][end]': [''], 'json_worktime[0][lunch_start]': [''], 'json_worktime[0][lunch_end]': [''], 'json_worktime[1][start]': ['01:00'], 'json_worktime[1][end]': [''], 'json_worktime[1][lunch_start]': [''], 'json_worktime[1][lunch_end]': [''], 'json_worktime[2][start]': [''], 'json_worktime[2][end]': [''], 'json_worktime[2][lunch_start]': [''], 'json_worktime[2][lunch_end]': [''], 'json_worktime[3][start]': [''], 'json_worktime[3][end]': [''], 'json_worktime[3][lunch_start]': [''], 'json_worktime[3][lunch_end]': [''], 'json_worktime[4][start]': [''], 'json_worktime[4][end]': [''], 'json_worktime[4][lunch_start]': [''], 'json_worktime[4][lunch_end]': [''], 'json_worktime[5][start]': [''], 'json_worktime[5][end]': [''], 'json_worktime[5][lunch_start]': [''], 'json_worktime[5][lunch_end]': [''], 'json_worktime[6][start]': [''], 'json_worktime[6][end]': [''], 'json_worktime[6][lunch_start]': [''], 'json_worktime[6][lunch_end]': [''], 'csrfmiddlewaretoken': ['gRaf2jfymU6AtnaYEq3UfurKRmfHD4MPNW6aap9zj3aYfNqkz72cjZsU6bilg6yb']}>
Далее я вынул это все из QueryDict:
json.dumps(request.POST)
Теперь это все имеем без QueryDict, но в неудобной форме.
Можно ли передать или преобразовать это в исходный вид, в котором был представлен пустой шаблон массива в коде JS?