If I make a request like so:
$.ajax({
url: '/some/url/',
data: {
normal_list: [1,2,3],
dict_list: [{foo:'a'}, {bar:'b'}]
}
})
... then I can't seem to get dict_list
out of request.GET
using getlist
. Here's what I see when I set up a breakpoint:
ipdb> request.GET
<QueryDict: {u'dict_list[1][bar]': [u'b'], u'normal_list[]': [u'1', u'2', u'3'], u'dict_list[0][foo]': [u'a']}>
ipdb> request.GET.getlist('normal_list[]')
[u'1', u'2', u'3']
ipdb> request.GET.getlist('dict_list[]')
[]
How do I get the correct value of dict_list
out of this request in django?
Edit: I am able to get it to work with dict_list: JSON.stringify([{foo:'a'}, {bar:'b'}])
, but I'd like to be able to send data in a way that is agnostic of the contents.