Commits

Anonymous committed 56e832b

Fixed #4270 -- Don't permit deleting of items from an immutable QueryDict.
Thanks, Gary Wilson.

Comments (0)

Files changed (2)

django/http/__init__.py

         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):

tests/regressiontests/httpwrappers/tests.py

 >>> q['name']
 'john'
 
+>>> del q['name']
+>>> 'name' in q
+False
+
+>>> q['name'] = 'john'
+
 >>> q.get('foo', 'default')
 'default'
 
 >>> 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