1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #26707 -- Added QueryDict.fromkeys()

This commit is contained in:
wim glenn
2016-06-03 15:50:38 -07:00
committed by Tim Graham
parent da22079c21
commit 5ebebd1159
5 changed files with 64 additions and 2 deletions

View File

@@ -402,6 +402,19 @@ class QueryDict(MultiValueDict):
value)
self._mutable = mutable
@classmethod
def fromkeys(cls, iterable, value='', mutable=False, encoding=None):
"""
Return a new QueryDict with keys (may be repeated) from an iterable and
values from value.
"""
q = cls('', mutable=True, encoding=encoding)
for key in iterable:
q.appendlist(key, value)
if not mutable:
q._mutable = False
return q
@property
def encoding(self):
if self._encoding is None: