Python interpreting QueryDict ambiguously. When I print request.POST
values, I see the values I'm expecting i.e 1 and 3
. However when I print the list, I see only 3
being printed.
(Pdb) request.POST
<QueryDict: {u'subjob_ids[]': [u' 1 ', u' 3 '], u'updated': [u''], u'created': [u''], u'job_name': [u'Job11'], u'jobtype_id': [u'1'], u'no_of_subjobs': [u'2'], u'operation': [u'addjobwithexistingsubjobs'], u'id': [u'-1']}>
(Pdb) request.POST['subjob_ids[]']
u' 3 '
Checked if this is problem with u
unicode, but it's not. When I convert unicode to str
, I see only 3
.
(Pdb) str(request.POST['subjob_ids[]'])
' 3 '
So is there a problem with the data present in QueryDict?
I tried taking this value into python interpreter instead of pdb, it just works perfectly.
>>> dict = {u'subjob_ids[]': [u' 1 ', u' 3 '], u'updated': [u''], u'created': [u''], u'job_name': [u'Job11'], u'jobtype_id': [u'1'], u'no_of_subjobs': [u'2'], u'operation': [u'addjobwithexistingsubjobs'], u'id': [u'-1']}
>>> dict
{u'subjob_ids[]': [u' 1 ', u' 3 '], u'jobtype_id': [u'1'], u'updated': [u''], u'no_of_subjobs': [u'2'], u'created': [u''], u'operation': [u'addjobwithexistingsubjobs'], u'job_name': [u'Job11'], u'id': [u'-1']}
>>> dict['subjob_ids[]']
[u' 1 ', u' 3 ']
>>> dict['subjob_ids[]'][0]
u' 1 '
>>> dict['subjob_ids[]'][1]
u' 3 '
Is there something wrong with how django is treating the data?