diff --git a/AUTHORS b/AUTHORS index 047ba919c1f..bf63b1057c4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -238,6 +238,7 @@ answer newbie questions, and generally made Django that much better: jcrasta@gmail.com jdetaeye jhenry + john@calixto.net Zak Johnson Nis Jørgensen Michael Josephson diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 3cbbe27b91c..4656f60f2bf 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -77,6 +77,27 @@ class MergeDict(object): """Returns a copy of this object.""" return self.__copy__() + def __str__(self): + ''' + Returns something like + + "{'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}" + + instead of the generic "" inherited from object. + ''' + return str(dict(self.items())) + + def __repr__(self): + ''' + Returns something like + + MergeDict({'key1': 'val1', 'key2': 'val2'}, {'key3': 'val3'}) + + instead of generic "" inherited from object. + ''' + dictreprs = ', '.join(repr(d) for d in self.dicts) + return '%s(%s)' % (self.__class__.__name__, dictreprs) + class SortedDict(dict): """ A dictionary that keeps its keys in the order in which they're inserted.