old_contents: from django.contrib.auth.models import User
  from rest_framework import serializers, viewsets
  
  
  class UserSerializer(serializers.HyperlinkedModelSerializer):
      class Meta:
          model = User
          fields = ('url', 'email')
  
  
  class UserViewSet(viewsets.ModelViewSet):
      queryset = User.objects.all()
      serializer_class = UserSerializer
  
new_contents: from django.contrib.auth.models import User
  from rest_framework import serializers, viewsets
  
  
  class UserSerializer(serializers.HyperlinkedModelSerializer):
      class Meta:
          model = User
          fields = ('url', 'email')
  
      def create(self, validated_data):
          user = User.objects.create(**validated_data)
          user.username = validated_data['email']
          user.save()
          return user
  
  
  class UserViewSet(viewsets.ModelViewSet):
      queryset = User.objects.all()
      serializer_class = UserSerializer
  
subject: Add user registration via api