From 97f22f29699476d5bcbbf599a3dba22909f4ec85 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Thu, 16 Jun 2011 16:34:55 +0000 Subject: 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 --- django/utils/datastructures.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'django/utils') 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 -- cgit v1.3