diff options
| author | Tom Christie | 2012-12-06 14:54:28 -0800 |
|---|---|---|
| committer | Tom Christie | 2012-12-06 14:54:28 -0800 |
| commit | 6ffcd7ba36c95c7398df2b5427eaef15ee1965a2 (patch) | |
| tree | d05efa9deb50c5392efe0cd8848cab719eb95760 /rest_framework/serializers.py | |
| parent | 6a5f4f2a90ab19a8586a9d762c9b2618e8db5c30 (diff) | |
| parent | cb7d9ea5c9843ffa99db4400670a11c3651520cc (diff) | |
| download | django-rest-framework-6ffcd7ba36c95c7398df2b5427eaef15ee1965a2.tar.bz2 | |
Merge pull request #477 from roberts81/master
Fix for #460
Diffstat (limited to 'rest_framework/serializers.py')
| -rw-r--r-- | rest_framework/serializers.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index e63f4783..67eafdf0 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -22,7 +22,16 @@ class DictWithMetadata(dict): """ A dict-like object, that can have additional properties attached. """ - pass + def __getstate__(self): + """ + Used by pickle (e.g., caching). + Overriden to remove metadata from the dict, since it shouldn't be pickled + and may in some instances be unpickleable. + """ + # return an instance of the first dict in MRO that isn't a DictWithMetadata + for base in self.__class__.__mro__: + if not isinstance(base, DictWithMetadata) and isinstance(base, dict): + return base(self) class SortedDictWithMetadata(SortedDict, DictWithMetadata): |
