From 1cb84cfa6d8d10876ea4e5207963728dedcb77e9 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 22 Dec 2020 13:15:12 +0200 Subject: [PATCH] Serializers: cleanup how we handle validation errors. --- django_etebase/serializers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/django_etebase/serializers.py b/django_etebase/serializers.py index 9408b78..24d78a4 100644 --- a/django_etebase/serializers.py +++ b/django_etebase/serializers.py @@ -149,10 +149,8 @@ class BetterErrorsMixin: ret.extend(self.flatten_errors("{}.{}".format(field_name, error_key), error)) else: for error in errors: - if hasattr(error, "detail"): - message = error.detail[0] - elif hasattr(error, "message"): - message = error.message + if error.messages: + message = error.messages[0] else: message = str(error) ret.append(