When I send an array of JavaScript objects to a Django view via AJAX, the object structure is as follows:
[{'oid':'id1','oiid':'iid1'},{'oid':'id2','oiid':'iid2'}]
This is how my AJAX request looks like:
....
type : "POST",
data : {action:'pack_orders',
order_dict:$checkedRows},
....
In the Django view, the request is received as a QueryDict with this format:
<QueryDict : {'order_dict[0][oid]':'id1','order_dict[0][oiid]':'iid1',
'order_dict[1][oid]':'id2','order_dict[1][oiid]':'iid2'}>
The challenge is to extract lists from the QueryDict in the Django view like so:
oid_list = ['id1','id2']
oiid_list = ['iid1','iid2']
The output in the views.py file should be:
{'order_dict[0][oid]':'id1','order_dict[0][oiid]':'iid1',
'order_dict[1][oid]':'id2','order_dict[1][oiid]':'iid2'}
An additional note: The output from the statement print dict(request.POST)
has been added to the views.py file.