title: Django-rest-framework serializer: Create an object with foreign objects at the same time
body: <p>Background: I have an Article model storing some articles and each article can have multiple images. I need to design an api to create an article and the corresponding images if necessary. But I have no ideas of how to make the images can be also created at the same time. </p>
  
  <p>models.py</p>
  
  <pre><code>class Article(models.Model):
      id = models.AutoField(primary_key=True)
      title = models.CharField(max_length=50)
      content = models.CharField(max_length=255) 
      def __unicode__(self):
          return self.title
  
  class ArticleImage(models.Model):
      id = models.AutoField(primary_key=True)
      image = models.ImageField(upload_to=get_file_path, blank=True, null=True)
      article = models.ForeignKey(Article)
  </code></pre>
  
  <p>serializers.py</p>
  
  <pre><code>class ArticleImageSerializer(serializers.ModelSerializer):
      class Meta:
          model = ArticleImage
  
  class ArticleSerializer(serializers.ModelSerializer):
      #images = ???
      class Meta:
          model = Article
  </code></pre>
  
  <p>api.py</p>
  
  <pre><code>class ArticleView(APIView):
      def post(self, request, format=None):
          try:
              serializer = ArticleSerializer(request.data)
              if serializer.is_valid():
                  serializer.save()
                  return Response({'success': True})
              else:
                  return Response({'success': False})
          except:
              return Response({'success': False})
  </code></pre>
  
  <p>Request JSON</p>
  
  <pre><code>{  
     "title":"Sample Title",
     "content":"Sample Content",
     "images":[  
        "paul.jpg",
        "ada.jpg"
     ]
  }
  </code></pre>
  
  <p>Thanks for help.</p>