Fixed #7331 -- Made `QueryDict.iteritems` behave like `QueryDict.items`, thanks jurev.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8399 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ddc156bca2
commit
2b82a3bcfc
|
@ -266,6 +266,14 @@ class MultiValueDict(dict):
|
||||||
"""
|
"""
|
||||||
return [(key, self[key]) for key in self.keys()]
|
return [(key, self[key]) for key in self.keys()]
|
||||||
|
|
||||||
|
def iteritems(self):
|
||||||
|
"""
|
||||||
|
Yields (key, value) pairs, where value is the last item in the list
|
||||||
|
associated with the key.
|
||||||
|
"""
|
||||||
|
for key in self.keys():
|
||||||
|
yield (key, self[key])
|
||||||
|
|
||||||
def lists(self):
|
def lists(self):
|
||||||
"""Returns a list of (key, list) pairs."""
|
"""Returns a list of (key, list) pairs."""
|
||||||
return super(MultiValueDict, self).items()
|
return super(MultiValueDict, self).items()
|
||||||
|
|
|
@ -42,6 +42,8 @@ MergeDict can merge MultiValueDicts
|
||||||
'Simon'
|
'Simon'
|
||||||
>>> d.getlist('name')
|
>>> d.getlist('name')
|
||||||
['Adrian', 'Simon']
|
['Adrian', 'Simon']
|
||||||
|
>>> list(d.iteritems())
|
||||||
|
[('position', 'Developer'), ('name', 'Simon')]
|
||||||
>>> d['lastname']
|
>>> d['lastname']
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
|
|
Loading…
Reference in New Issue