text: from rest_framework import status
  from rest_framework.generics import CreateAPIView
  from rest_framework.response import Response
  from rest_framework.permissions import AllowAny
  from rest_framework_simplejwt.views import TokenObtainPairView
  from rest_framework_simplejwt.tokens import RefreshToken
  
  from .serializers import UserRegistrationSerializer, CustomTokenObtainPairSerializer
  
  
  class CustomTokenObtainPairView(TokenObtainPairView):
      serializer_class = CustomTokenObtainPairSerializer
  
  
  class UserRegistrationView(CreateAPIView):
  
      serializer_class = UserRegistrationSerializer
      permission_classes = (AllowAny,)
  
      def post(self, request):
          '''Create new user and return tokens for this user (include user id)'''
          serializer = self.serializer_class(data=request.data)
          serializer.is_valid(raise_exception=True)
          user = serializer.save()
  
          refresh = RefreshToken.for_user(user)
          token = {
              'refresh': str(refresh),
              'access': str(refresh.access_token),
          }
  
          status_code = status.HTTP_201_CREATED
          response = {
              'success': 'True',
              'status_code': status_code,
              'message': 'User registered successfully',
              'token': token
          }
  
          return Response(response, status=status_code)
  