Maintain a reference to the parent serializer when descending down into fields

This commit is contained in:
Alen Mujezinovic 2012-03-01 12:46:38 +00:00
parent 55317b0372
commit 54a19105f0

View File

@ -133,6 +133,7 @@ class Serializer(object):
if isinstance(info, (list, tuple)): if isinstance(info, (list, tuple)):
class OnTheFlySerializer(self.__class__): class OnTheFlySerializer(self.__class__):
fields = info fields = info
parent = getattr(self, 'parent', self)
return OnTheFlySerializer return OnTheFlySerializer
# If an element in `fields` is a 2-tuple of (str, Serializer) # If an element in `fields` is a 2-tuple of (str, Serializer)