diff --git a/django/http/__init__.py b/django/http/__init__.py index a0c51ff0da..74a4eff55c 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -91,6 +91,10 @@ class QueryDict(MultiValueDict): self._assert_mutable() MultiValueDict.__setitem__(self, key, value) + def __delitem__(self, key): + self._assert_mutable() + super(QueryDict, self).__delitem__(key) + def __copy__(self): result = self.__class__('', mutable=True) for key, value in dict.items(self): diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py index 29cb8385e0..c8016bc5bd 100644 --- a/tests/regressiontests/httpwrappers/tests.py +++ b/tests/regressiontests/httpwrappers/tests.py @@ -96,6 +96,12 @@ MultiValueDictKeyError: "Key 'foo' not found in " >>> q['name'] 'john' +>>> del q['name'] +>>> 'name' in q +False + +>>> q['name'] = 'john' + >>> q.get('foo', 'default') 'default' @@ -367,6 +373,11 @@ AttributeError: This QueryDict instance is immutable >>> q.urlencode() 'vote=yes&vote=no' +>>> del q['vote'] +Traceback (most recent call last): +... +AttributeError: This QueryDict instance is immutable + """ from django.http import QueryDict