diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index f27bc1c..073c3da 100644
a
|
b
|
class MultiValueDict(dict):
|
172 | 172 | 'Simon' |
173 | 173 | >>> d.getlist('name') |
174 | 174 | ['Adrian', 'Simon'] |
| 175 | >>> d.getlist('doesnotexist') |
| 176 | [] |
| 177 | >>> d.getlist('doesnotexist', ['Adrian', 'Simon']) |
| 178 | ['Adrian', 'Simon'] |
175 | 179 | >>> d.get('lastname', 'nonexistent') |
176 | 180 | 'nonexistent' |
177 | 181 | >>> d.setlist('lastname', ['Holovaty', 'Willison']) |
… |
… |
class MultiValueDict(dict):
|
231 | 235 | return default |
232 | 236 | return val |
233 | 237 | |
234 | | def getlist(self, key): |
| 238 | def getlist(self, key, default=None): |
235 | 239 | """ |
236 | 240 | Returns the list of values for the passed key. If key doesn't exist, |
237 | 241 | then an empty list is returned. |
… |
… |
class MultiValueDict(dict):
|
239 | 243 | try: |
240 | 244 | return super(MultiValueDict, self).__getitem__(key) |
241 | 245 | except KeyError: |
| 246 | if default is not None: |
| 247 | return default |
242 | 248 | return [] |
243 | 249 | |
244 | 250 | def setlist(self, key, list_): |
diff --git a/docs/request_response.txt b/docs/request_response.txt
index 54fc24d..1c3640c 100644
a
|
b
|
All attributes except ``session`` should be considered read-only.
|
80 | 80 | strings. |
81 | 81 | |
82 | 82 | ``FILES`` |
83 | | |
| 83 | |
84 | 84 | .. admonition:: Changed in Django development version |
85 | | |
| 85 | |
86 | 86 | In previous versions of Django, ``request.FILES`` contained |
87 | 87 | simple ``dict`` objects representing uploaded files. This is |
88 | 88 | no longer true -- files are represented by ``UploadedFile`` |
89 | 89 | objects as described below. |
90 | | |
| 90 | |
91 | 91 | These ``UploadedFile`` objects will emulate the old-style ``dict`` |
92 | 92 | interface, but this is deprecated and will be removed in the next |
93 | 93 | release of Django. |
94 | | |
| 94 | |
95 | 95 | A dictionary-like object containing all uploaded files. Each key in |
96 | 96 | ``FILES`` is the ``name`` from the ``<input type="file" name="" />``. Each |
97 | 97 | value in ``FILES`` is an ``UploadedFile`` object containing the following |
… |
… |
All attributes except ``session`` should be considered read-only.
|
102 | 102 | * ``file_size`` -- The size, in bytes, of the uploaded file. |
103 | 103 | * ``chunk()`` -- A generator that yields sequential chunks of data. |
104 | 104 | |
105 | | See `File Uploads`_ for more information. |
106 | | |
| 105 | See `File Uploads`_ for more information. |
| 106 | |
107 | 107 | Note that ``FILES`` will only contain data if the request method was POST |
108 | 108 | and the ``<form>`` that posted to the request had |
109 | 109 | ``enctype="multipart/form-data"``. Otherwise, ``FILES`` will be a blank |
110 | 110 | dictionary-like object. |
111 | | |
| 111 | |
112 | 112 | .. _File Uploads: ../upload_handling/ |
113 | 113 | |
114 | 114 | ``META`` |
… |
… |
In addition, ``QueryDict`` has the following methods:
|
305 | 305 | from the Python standard library. The copy will be mutable -- that is, |
306 | 306 | you can change its values. |
307 | 307 | |
308 | | * ``getlist(key)`` -- Returns the data with the requested key, as a Python |
309 | | list. Returns an empty list if the key doesn't exist. It's guaranteed to |
310 | | return a list of some sort. |
| 308 | * ``getlist(key, default)`` -- Returns the data with the requested key, as |
| 309 | a Python list. Returns an empty list if the key doesn't exist and no |
| 310 | default value was provided. It's guaranteed to return a list of some sort |
| 311 | unless the default value was no list. |
311 | 312 | |
312 | 313 | * ``setlist(key, list_)`` -- Sets the given key to ``list_`` (unlike |
313 | 314 | ``__setitem__()``). |