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
  • 3,871
  • 5
  • 28
  • 48

1 Answers1

8

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

qd.getlist('songs')
Alasdair
  • 278,338
  • 51
  • 534
  • 489