old_contents: from rest_framework import serializers
  from polls.models import Question, Choice
          
  class ChoiceSerializer(serializers.HyperlinkedModelSerializer):
      class Meta:
          model = Choice
          fields = ('url', 'choice_text', 'votes')
          
  class QuestionSerializer(serializers.HyperlinkedModelSerializer):
      choices = ChoiceSerializer(many=True)
      
      class Meta:
          model = Question
          fields = ('url', 'question_text', 'choices',)
          
      def create(self, validated_data):
          choices_data = validated_data.pop('choices')
          question = Question.objects.create(**validated_data)
          
          for choice_data in choices_data:
              Choice.objects.create(question=question, **choice_data)
          
          return question        
          
      
new_contents: from rest_framework import serializers
  from polls.models import Question, Choice
          
  class ChoiceSerializer(serializers.HyperlinkedModelSerializer):
      class Meta:
          model = Choice
          fields = ('url', 'choice_text', 'votes')
          read_only_fields = ('votes',)
          
  class QuestionSerializer(serializers.HyperlinkedModelSerializer):
      choices = ChoiceSerializer(many=True)
      
      class Meta:
          model = Question
          fields = ('url', 'question_text', 'choices',)
          
      def create(self, validated_data):
          choices_data = validated_data.pop('choices')
          question = Question.objects.create(**validated_data)
          
          for choice_data in choices_data:
              Choice.objects.create(question=question, **choice_data)
          
          return question        
          
      
subject: make votes readonly