MCPcopy Index your code
hub / github.com/encode/django-rest-framework / data

Method data

rest_framework/serializers.py:238–256  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

236
237 @property
238 def data(self):
239 if hasattr(self, 'initial_data') and not hasattr(self, '_validated_data'):
240 msg = (
241 'When a serializer is passed a `data` keyword argument you '
242 'must call `.is_valid()` before attempting to access the '
243 'serialized `.data` representation.\n'
244 'You should either call `.is_valid()` first, '
245 'or access `.initial_data` instead.'
246 )
247 raise AssertionError(msg)
248
249 if not hasattr(self, '_data'):
250 if self.instance is not None and not getattr(self, '_errors', None):
251 self._data = self.to_representation(self.instance)
252 elif hasattr(self, '_validated_data') and not getattr(self, '_errors', None):
253 self._data = self.to_representation(self.validated_data)
254 else:
255 self._data = self.get_initial()
256 return self._data
257
258 @property
259 def errors(self):

Callers

nothing calls this directly

Calls 2

to_representationMethod · 0.95
get_initialMethod · 0.45

Tested by

no test coverage detected