I\'m sending an Ajax request (with jQuery) with structured post data:
$.post(
myUrl,
{
items: [{code: \'a\', description: \'aaa\'},
I made special library for Django/Python to handle structured data sent through requests. You can find it on GitHub here.
I'd suggest you post your object as JSON. In Django, you then can recreate the structure by parsing the JSON into python objects.
Post JSON with jQuery
$.post(
myUrl,
JSON.stringify({
items: [{code: 'a', description: 'aaa'},
{code: 'b', description: 'bbb'}]
})
)
Parsing JSON in Django view
from django.http import HttpResponse
from django.utils import simplejson
def my_view(request):
if request.method == 'POST':
json_data = simplejson.loads(request.raw_post_data)
# json_data contains your objects
print json_data['items']
return HttpResponse("Got data")
You could try:
request.POST.getlist('items')