text: from rest_framework import serializers
  from .models import Movie, Rating
  from django.contrib.auth.models import User
  from rest_framework.authtoken.models import Token
  
  
  class UserSerializer(serializers.ModelSerializer):
      class Meta:
          model = User
          # we need to hash the password before adding it to the database
          fields = ('id', 'username', 'password')
          extra_kwargs = {'password': {'write_only': True, 'required': True}}
  
      # the default built-in function show the password. Override the default function
      # we override the built-in function to create new user
      # Should we implement the create function in Model or ModelSerializer ?
      # By default the token is not created and so we need to create a token for the user
      def create(self, validated_data):
          user = User.objects.create_user(**validated_data)
          Token.objects.create(user=user)
          return user
  
  
  class MovieSerializer(serializers.ModelSerializer):
      class Meta:
          model = Movie
          fields = ('id', 'title', 'description', 'no_of_ratings', 'avg_ratings')
  
  
  class RatingSerializer(serializers.ModelSerializer):
      class Meta:
          model = Rating
          fields = ('id', 'stars', 'user', 'movie')
  