request: get multiple values | Django


/ Published in: Django
Save to your folder(s)



Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.