Thanks so much

On Thursday, August 7, 2014 4:38:28 PM UTC-6, Tom Evans wrote:
>
> On Thu, Aug 7, 2014 at 10:27 PM, G Z <zuk...@gmail.com <javascript:>> 
> wrote: 
> > I'm doing some query and database stuff outside of what django is 
> capable of 
> > and I need some help with how I get all the values of a POSTED 
> Dictionary 
> > list. 
> > 
> > here is the POST values because im using a multiple select box that are 
> send 
> > to django 
> > u'licenses': [u'26.0', u'16.0', u'13.0', u'166.0'], 
> > 
> > I need to insert these licenses for the vm that was selected. Thus, I 
> need 
> > to be able to get at each one and save into a list. 
> > However all I can seem to get to is the very last one. This has 
> something to 
> > do with the way django is parsing the information. 
> > 
> > So here is my code: 
> > I've tried teh following: 
> > 
> >> selected_lic.append(selected_customer['licenses']) 
> > 
> > 
> > This will output the following 
> > [u'166.0'] 
> > 
> >> for license in selected_customer['licenses']: 
> >>       selected_lic.append(license) 
> > 
> > This will out put the following 
> > [u'1','6','6','.','0'] 
> > 
> > Why can't i get to the rest of the data? Why does it only take the last 
> > value. Even if I just set a var to the selected post value it will only 
> take 
> > the last one. 
> > 
> > [u'166.0'] 
> > 
>
> QueryDict objects do not work like that, if you simply index the 
> QueryDict by keyname, and the key refers to a list of values, then the 
> last value in the list is returned. It is a string, and you are then 
> iterating through that character by character. 
>
>
> https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.QueryDict.__getitem__
>  
>
> Use QueryDict.getlist() instead: 
>
>
> https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.QueryDict.getlist
>  
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a1bf73dd-4160-4b6c-88a1-41c094ffa526%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to