how to obtain all values of a multi-valued key from Django's request.GET QueryDict

后端 未结 7 968
花落未央
花落未央 2021-02-07 04:11

The Django docs say at http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict.iteritems thatQueryDict.iteritems() uses the same last-value

相关标签:
7条回答
  • 2021-02-07 05:08

    This should work:

    mstring = []
    for key in request.GET.iterkeys():  # "for key in request.GET" works too.
        # Add filtering logic here.
        valuelist = request.GET.getlist(key)
        mstring.extend(['%s=%s' % (key, val) for val in valuelist])
    print '&'.join(mstring)
    
    0 讨论(0)
提交回复
热议问题