from apps.userprofile.models import UserProfile as UserProfileModel from rest_framework.validators import ValidationError def get_user_profile(user_id: int): try: return UserProfileModel.objects.get(cuser_id=user_id) except UserProfileModel.DoesNotExist: raise ValidationError("User profile does not exist") except Exception as exp: raise ValidationError(exp)