Serializers: fix an issue with handling validation errors.

This commit is contained in:
Tom Hacohen 2020-12-24 16:14:52 +02:00
parent 7eb08d2946
commit 2de51b978a

View File

@ -149,7 +149,7 @@ class BetterErrorsMixin:
ret.extend(self.flatten_errors("{}.{}".format(field_name, error_key), error))
else:
for error in errors:
if error.messages:
if getattr(error, "messages", None):
message = error.messages[0]
else:
message = str(error)