summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-06-16 16:34:55 +0000
committerJannis Leidel <jannis@leidel.info>2011-06-16 16:34:55 +0000
commit97f22f29699476d5bcbbf599a3dba22909f4ec85 (patch)
treefcdef059c7c18978bd2e1a4873b1c1c57ff8ec72 /django/utils
parentdfa29161e2eff676eb4aa187f76c157556dfc5db (diff)
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
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/datastructures.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index b0b449c76d..46f705f747 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -391,6 +391,12 @@ class MultiValueDict(dict):
for key, value in kwargs.iteritems():
self.setlistdefault(key, []).append(value)
+ def dict(self):
+ """
+ Returns current object as a dict with singular values.
+ """
+ return dict((key, self[key]) for key in self)
+
class DotExpandedDict(dict):
"""
A special dictionary constructor that takes a dictionary in which the keys