Fix not falling into initial data

This commit is contained in:
Ruslan Chernenko 2022-11-04 20:38:18 +03:00 committed by GitHub
parent 2486dbf791
commit f589cfb0be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,7 +250,7 @@ class BaseSerializer(Field):
)
raise AssertionError(msg)
if not hasattr(self, '_data') and not getattr(self, '_errors', None):
if not hasattr(self, '_data') or getattr(self, '_errors', None):
if self.instance is not None:
self._data = self.to_representation(self.instance)
elif hasattr(self, '_validated_data'):