title: How to deserialize nested objects with Django Rest Framework
body: <p>Say I have Django models like this:</p>
  
  <pre><code>class Book(models.Model):
    title = models.CharField(max_length=150)
    author = models.CharField(max_length=150) 
  
  class Chapter(models.Model):
    book = models.ForeignKey(Book, related_name='chapters')
    title = models.CharField(max_length=150)
    page_num = models.IntegerField()
  </code></pre>
  
  <p>and Django Rest Framework classes like this:</p>
  
  <pre><code>class ChapterSerializer(serializers.ModelSerializer):
    class Meta:
      model = Chapter
      fields = ('id', 'title', 'page_num')
  
  class BookSerializer(serializers.ModelSerializer):
    chapters = ChapterSerializer(many=True)
  
    class Meta:
      model = Book
      fields = ('id', 'title', 'author', 'chapters')
  
    def create(validated_data):
      chapters = validated_data.pop('chapters')
      book = Book(**validated_data)
      book.save()
      serializer = ChapterSerializer(data=chapters, many=True)
      if serializer.is_valid(raise_exception=True):
          chapters = serializer.save()
  
  class BookCreate(generics.CreateAPIView):
    serializer = BookSerializer(data=request.data)
    if serializer.is_valid(raise_exception=True):
      serializer.save()
    # Do some other stuff
  </code></pre>
  
  <p>and I POST some JSON like this:</p>
  
  <pre><code>{
    title: "Test book",
    author: "Test author",
    chapters: [
      {title: "Test chapter 1", page_num: 1},
      {title: "Test chapter 2", page_num: 5}
    ]
  }
  </code></pre>
  
  <p>I get an exception because <code>chapter</code> doesn't have a <code>book</code> associated with it. If I add <code>book</code> as one of the fields of <code>ChapterSerializer</code>, then the JSON will fail to validate because the <code>BookSerializer</code> in <code>BookCreate</code> won't validate because it will expect a book id  for the chapters, but the book hasn't been created yet. How do I resolve this situation?</p>
  
  <p>Is there a way to have the <code>BookSerializer</code> to validate its own fields and not to validate its <code>chapter</code>'s?</p>