This commit is contained in:
Samir Otiv 2017-05-31 21:01:01 +00:00 committed by GitHub
commit 4f71569af4

View File

@ -351,6 +351,16 @@ class Serializer(BaseSerializer):
'invalid': _('Invalid data. Expected a dictionary, but got {datatype}.') 'invalid': _('Invalid data. Expected a dictionary, but got {datatype}.')
} }
@property
def depth(self):
if not hasattr(self, '_depth'):
self._depth = getattr(self.Meta, 'depth', 0)
return self._depth
@depth.setter
def depth(self, value):
self._depth = value
@property @property
def fields(self): def fields(self):
""" """
@ -983,7 +993,7 @@ class ModelSerializer(Serializer):
declared_fields = copy.deepcopy(self._declared_fields) declared_fields = copy.deepcopy(self._declared_fields)
model = getattr(self.Meta, 'model') model = getattr(self.Meta, 'model')
depth = getattr(self.Meta, 'depth', 0) depth = self.depth
if depth is not None: if depth is not None:
assert depth >= 0, "'depth' may not be negative." assert depth >= 0, "'depth' may not be negative."