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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user