text: from rest_framework import serializers
  from rest_framework.authtoken.models import Token
  from django.contrib.auth import get_user_model
  
  
  UserModel = get_user_model()
  
  
  class TokenSerializer(serializers.ModelSerializer):
      class Meta:
          model = Token
          fields = ['key']
  
  
  class UserSerializer(serializers.ModelSerializer):
  
      password = serializers.CharField(write_only=True)
  
      def create(self, validated_data):
          user = UserModel.objects.create_user(
              username=validated_data['username'],   #for unique username and login with email as username
              email=validated_data['email'],
              password=validated_data['password'],
          )
  
          return user
  
      class Meta:
          model = UserModel
          fields = ("id", "username", "email", "password",)
  