QueryDict objects
In an HttpRequest
object, the GET
and POST
attributes are instances of django.http.QueryDict
, a dictionary-like class customized to deal with multiple values for the same key. This is necessary because some HTML form elements, notably <select multiple>
, pass multiple values for the same key.
The QueryDict
s at request.POST
and request.GET
will be immutable when accessed in a normal request/response cycle. To get a mutable version you need to use .copy()
.
Methods
QueryDict
implements all the standard dictionary methods because it's a subclass of dictionary, with the following exceptions.
QueryDict.__init__()
Instantiates a QueryDict
object based on query_string
.
>>> QueryDict('a=1&a=2&c=3') <QueryDict: {'a': ['1', '2'], 'c': ['3']}> ...
Get Mastering Django: Core now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.