From 8f47bc9d14aec9a1ed495a13ef333e676489d4eb Mon Sep 17 00:00:00 2001 From: Daniel Gilge <33256939+dgilge@users.noreply.github.com> Date: Wed, 21 Nov 2018 10:41:00 +0100 Subject: [PATCH] Add as_serializer_error for consistent error messages --- rest_auth/registration/serializers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest_auth/registration/serializers.py b/rest_auth/registration/serializers.py index 9dc6f3a..2271f1e 100644 --- a/rest_auth/registration/serializers.py +++ b/rest_auth/registration/serializers.py @@ -211,8 +211,10 @@ class RegisterSerializer(serializers.Serializer): user = adapter.save_user(request, user, self, commit=False) try: adapter.clean_password(self.cleaned_data['password1'], user=user) - except DjangoValidationError as e: - raise serializers.ValidationError(e.messages) + except DjangoValidationError as exc: + raise serializers.ValidationError( + detail=serializers.as_serializer_error(exc) + ) user.save() self.custom_signup(request, user) setup_user_email(request, user, [])