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

后端 未结 7 1171
花落未央
花落未央 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条回答
  •  旧时难觅i
    2021-02-07 04:47

    There is a useful function in django http utils you can use:

    >>> from django.utils.http import urlencode
    >>> print(urlencode({"tag": [1, 2, 3], "sentence":2}, doseq=True))
    
    'tag=1&tag=2&tag=3&sentence=2'
    

提交回复
热议问题