diff options
author | wim glenn <git@wimglenn.com> | 2016-06-03 15:50:38 -0700 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-06-06 08:54:25 -0400 |
commit | 5ebebd1159b4bacfce1999e41831081679b6f35a (patch) | |
tree | f1f650aa337968ac5893b87bc6049f29273ddec6 /django/http/request.py | |
parent | da22079c21a02c65e31502dd05720d12c474b257 (diff) | |
download | django-5ebebd1159b4bacfce1999e41831081679b6f35a.tar.gz |
Fixed #26707 -- Added QueryDict.fromkeys()
Diffstat (limited to 'django/http/request.py')
-rw-r--r-- | django/http/request.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/django/http/request.py b/django/http/request.py index f3754ba2ff..84230be6e0 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -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: |