title: Django REST Framework POST nested objects
body: <p>I'm facing a little problem right now with <em>Django Rest Framework</em>. I'm trying to post an object with nested objects in it.</p>
  
  <p>Here are my <code>serializers.py</code>:</p>
  
  <pre><code>class ClassSerializer(serializers.ModelSerializer):
      class Meta:
          model = Class
          fields = ('number', 'letter')
  
  
  class SubjectSerializer(serializers.ModelSerializer):
      class Meta:
          model = Subject
          fields = ('title',)
  
  
  class ExamSerializer(serializers.ModelSerializer):
      subject = SubjectSerializer()
      clazz = ClassSerializer()
  
      class Meta:
          model = Exam
          fields = ('id', 'subject', 'clazz', 'topic', 'date', 'details')
          depth = 1
  
      def create(self, validated_data):
          return Exam.objects.create(**validated_data)
  
      def update(self, instance, validated_data):
          instance.__dict__.update(**validated_data)
          instance.save()
  
          return instance
  </code></pre>
  
  <p>And <code>create()</code> from <code>views.py</code>:</p>
  
  <pre><code>def create(self, request):
      serializer = self.serializer_class(data=request.data)
      serializer.is_valid(raise_exception=True)
      self.perform_create(serializer)
  
      return Response(serializer.validated_data, status=status.HTTP_201_CREATED)
  </code></pre>
  
  <p>And here it is the response from <em>Postman</em>:
  <a href="https://i.stack.imgur.com/SIjVC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SIjVC.png" alt="Postman response"></a></p>
  
  <p>I've read some posts here about this problem but I'm still stuck with it. I've tried to fix it in several ways but it is still returning <code>"This field is required."</code>.</p>