diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index b0b449c..46f705f 100644
a
|
b
|
class MultiValueDict(dict):
|
391 | 391 | for key, value in kwargs.iteritems(): |
392 | 392 | self.setlistdefault(key, []).append(value) |
393 | 393 | |
| 394 | def dict(self): |
| 395 | """ |
| 396 | Returns current object as a dict with singular values. |
| 397 | """ |
| 398 | return dict((key, self[key]) for key in self) |
| 399 | |
394 | 400 | class DotExpandedDict(dict): |
395 | 401 | """ |
396 | 402 | A special dictionary constructor that takes a dictionary in which the keys |
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
index ff04e25..a023ed4 100644
a
|
b
|
In addition, ``QueryDict`` has the following methods:
|
482 | 482 | >>> q.lists() |
483 | 483 | [(u'a', [u'1', u'2', u'3'])] |
484 | 484 | |
| 485 | .. method:: QueryDict.dict() |
| 486 | |
| 487 | Returns ``dict`` representation of ``QueryDict``. For every (key, list) |
| 488 | pair in ``QueryDict``, ``dict`` will have (key, item), where item is one |
| 489 | element of the list, using same logic as :meth:`QueryDict.__getitem__()`:: |
| 490 | |
| 491 | >>> q = QueryDict('a=1&a=3&a=5') |
| 492 | >>> q.dict() |
| 493 | {u'a': u'5'} |
| 494 | |
| 495 | .. versionadded:: 1.4 |
| 496 | |
485 | 497 | .. method:: QueryDict.urlencode([safe]) |
486 | 498 | |
487 | 499 | Returns a string of the data in query-string format. Example:: |
diff --git a/tests/regressiontests/utils/datastructures.py b/tests/regressiontests/utils/datastructures.py
index 2f1a47a..88b83f7 100644
a
|
b
|
class MultiValueDictTests(DatastructuresTestCase):
|
235 | 235 | self.assertEqual(d1["key"], ["Penguin"]) |
236 | 236 | self.assertEqual(d2["key"], ["Penguin"]) |
237 | 237 | |
| 238 | def test_dict_translation(self): |
| 239 | mvd = MultiValueDict({ |
| 240 | 'devs': ['Bob', 'Joe'], |
| 241 | 'pm': ['Rory'], |
| 242 | }) |
| 243 | d = mvd.dict() |
| 244 | self.assertEqual(d.keys(), mvd.keys()) |
| 245 | for key in mvd.keys(): |
| 246 | self.assertEqual(d[key], mvd[key]) |
| 247 | |
| 248 | self.assertEqual({}, MultiValueDict().dict()) |
| 249 | |
238 | 250 | |
239 | 251 | class DotExpandedDictTests(DatastructuresTestCase): |
240 | 252 | |