diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index a2b78a31c5..4c278c0d8e 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -155,6 +155,10 @@ class SortedDict(dict): """ return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()]) + def clear(self): + super(SortedDict, self).clear() + self.keyOrder = [] + class MultiValueDictKeyError(KeyError): pass diff --git a/tests/regressiontests/datastructures/tests.py b/tests/regressiontests/datastructures/tests.py index 172057f080..b51b4b1233 100644 --- a/tests/regressiontests/datastructures/tests.py +++ b/tests/regressiontests/datastructures/tests.py @@ -101,6 +101,12 @@ Init from sequence of tuples >>> print repr(d) {1: 'one', 0: 'zero', 2: 'two'} +>>> d.clear() +>>> d +{} +>>> d.keyOrder +[] + ### DotExpandedDict ############################################################ >>> d = DotExpandedDict({'person.1.firstname': ['Simon'], 'person.1.lastname': ['Willison'], 'person.2.firstname': ['Adrian'], 'person.2.lastname': ['Holovaty']})