text: from rest_framework import serializers
  from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
  from rest_framework_simplejwt.tokens import RefreshToken
  
  from .models import User
  
  
  class UserSerializer(serializers.ModelSerializer):
      class Meta:
          model = User
          fields = ['id', 'email', 'name', 'isAdmin']
  
  
  class TokenSerializer(serializers.ModelSerializer):
      token = serializers.SerializerMethodField(read_only=True)
  
      class Meta:
          model = User
          fields = ['id', 'email', 'name', 'isAdmin', 'token']
  
      def get_token(self, obj):
          token = RefreshToken.for_user(obj)
          return str(token.access_token)
  
  
  class LoginSerializer(TokenObtainPairSerializer):
      def validate(self, attrs):
          data = super().validate(attrs)
          serializer = TokenSerializer(self.user).data
          for key, value in serializer.items():
              data[key] = value
          return data
  