user_management/api/serializers.py
def validate_email(self, email):
        """
        Validate if email exists and requires a verification.

        `validate_email` will set a `user` attribute on the instance allowing
        the view to send an email confirmation.
        """
        try:
            self.user = User.objects.get_by_natural_key(email)
        except User.DoesNotExist:
            msg = _('A user with this email address does not exist.')
            raise serializers.ValidationError(msg)

        if self.user.email_verified:
            msg = _('User email address is already verified.')
            raise serializers.ValidationError(msg)
        return email
def validate_email(self, email):
        """
        Validate if email exists and requires a verification.

        `validate_email` will set a `user` attribute on the instance allowing
        the view to send an email confirmation.
        """
        try:
            self.user = User.objects.get_by_natural_key(email)
        except User.DoesNotExist:
            msg = _('A user with this email address does not exist.')
            raise serializers.ValidationError(msg)

        if self.user.email_verified:
            msg = _('User email address is already verified.')
            raise serializers.ValidationError(msg)
        return email
Validate if email exists and requires a verification.

        `validate_email` will set a `user` attribute on the instance allowing
        the view to send an email confirmation.