Posted By

magicrebirth on 03/26/11


Tagged

get post request getlist


Versions (?)

request: get multiple values | Django


 / Published in: Django
 

URL: http://www.djangofoo.com/93/request-post-get-multiple-values

  1. # getting multiple values:
  2.  
  3. testargs = request.GET.getlist('testargs')
  4. # getlist gets all parameters with same name!!!!
  5.  
  6.  
  7.  
  8. # constructing the url:
  9.  
  10. >>> from django.http import QueryDict
  11. >>> q = QueryDict(‘artists=1).copy()
  12. >>> my_artists = [11,22,33,44]
  13. >>> q.setlist(‘artists’, my_artists)
  14. >>> print q
  15. <QueryDict: {u’artists’: [11, 22, 33, 44]}>
  16. >>> print q.urlencode()
  17. artists=11&artists=22&artists=33&artists=44

Report this snippet  

You need to login to post a comment.