mirror of
https://github.com/django/django.git
synced 2025-11-01 20:31:40 +00:00
Fixed #12375 -- Added a dict() method to convert a MultiValueDict (such as a QueryDict) to a dictionary of key-value pairs. Thanks, oinopion and hvdklauw.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16418 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
dfa29161e2
commit
97f22f2969
3 changed files with 30 additions and 0 deletions
|
|
@ -235,6 +235,18 @@ class MultiValueDictTests(DatastructuresTestCase):
|
|||
self.assertEqual(d1["key"], ["Penguin"])
|
||||
self.assertEqual(d2["key"], ["Penguin"])
|
||||
|
||||
def test_dict_translation(self):
|
||||
mvd = MultiValueDict({
|
||||
'devs': ['Bob', 'Joe'],
|
||||
'pm': ['Rory'],
|
||||
})
|
||||
d = mvd.dict()
|
||||
self.assertEqual(d.keys(), mvd.keys())
|
||||
for key in mvd.keys():
|
||||
self.assertEqual(d[key], mvd[key])
|
||||
|
||||
self.assertEqual({}, MultiValueDict().dict())
|
||||
|
||||
|
||||
class DotExpandedDictTests(DatastructuresTestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue