MultiValueDict is a subclass of a dictionary that can handle multiple values ββassigned to a key. Therefore, you must pass the values from the dict as list . here 1->[1] .
In the HttpRequest object, the GET and POST attributes are instances of django.http.QueryDict, a dictionary-like class configured to handle multiple values ββfor the same key. This is necessary because some elements of the HTML form, in particular, pass multiple values ββfor the same key.
QueryDicts for .POST and request.GET will be unchanged when accessed in the normal request / response loop. To get the modified version you need to use .copy ().
Then MultiValueDict can be converted to QueryDict as
abc = { 'a': [1], 'b':[1,2,3]} mdict = MultiValueDict(abc) qdict = QueryDict('', mutable=True) qdict.update(mdict) >>>QueryDict: {u'a': [1], u'b': [1, 2, 3]}> >>>dict(qdict.iterlists()) {u'a': [1], u'b': [1, 2, 3]} >>>qdict.getlist('b') [1, 2, 3]
source share