1

Django 1.7 Python 2.7

I have a QueryDict object (let's name it qd):

<QueryDict: {u'org': [u''], u'songs': [u'1', u'2'], u'user': [u'222'], u'name': [u'test_name']}>

but I can't seem to get the 'songs' value.

I've tried:

qd.get('songs')
qd['songs']
qd.__getitem__('songs')

but they all return u'2' .

Why can't I get a list, it seems so trivial?

Saša Kalaba
  • 4,241
  • 6
  • 29
  • 52

1 Answers1

9

You should use getlist to return the data as a list:

qd.getlist('songs')
Alasdair
  • 298,606
  • 55
  • 578
  • 516