Closed
Description
Example test case I think illustrates the issue:
https://github.com/mathspace/django-rest-framework/compare/validation-race
If I call self.data
inside a serializer.validate
, the existing stale instance data ends up cached on serializer._data
. The workaround that passed my tests was to access serializer.instance
instead.
Curious as to thoughts on this, e.g.
- Should
serializer.data
be accessible inside the validate methods, i.e. while the serializer is essentially still under construction? - Or should the
_data
cache be appropriately flushed so the test can pass?
I would lean towards the former only because the serializer.data
by being partly constructed could be quite misleading.
Metadata
Metadata
Assignees
Labels
No labels