Wednesday, February 29, 2012

AW: Post data Query Dict - Why not a list ?

Exactly what i was looking for...thx a lot!


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
XSLT Developer
LexisNexis
A-1030 Wien, Marxergasse 25

mailto:patrick.szabo@lexisnexis.at
Tel.: +43 1 53452 1573
Fax: +43 1 534 52 146


-----Ursprüngliche Nachricht-----

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im Auftrag von Masklinn
Gesendet: Mittwoch, 29. Februar 2012 10:03
An: django-users@googlegroups.com
Betreff: Re: Post data Query Dict - Why not a list ?

On 2012-02-29, at 09:46 , Szabo, Patrick (LNG-VIE) wrote:
> Hi,
>
> If i do
>
> for key in request.POST.keys():
>
> print request.POST[key]
>
> Over this (which is the result of print request.Post):
>
> <QueryDict: {u'hix': [u'Monatsreport'], u'my_choice_field': [u'2',
> u'29', u'42']}>
>
> I get:
>
> Monatsreport
>
> 42
>
> Should I not get lists ?

No, multidicts generally conform to the dict interface (mapping a
key to a value) as it's the most useful way to interact with POSTDATA
(or GETDATA for that matter): people will generally map a single value
to each key and having to unpack that value all the time is a pain.

If you want to get all values for the key, as the documentation
indicates[0] you should use the `getlist` method.

[0] https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict.getlist

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment