title: How to POST a nested data and list of image
body: <p>There are two models: <code>Product</code> and <code>Picture</code>. Each <code>Product</code> can have several <code>Picture</code>s. I have questions when I want to create a Product using POST. How to POST a nested object containing a ImageField list?</p>
  
  <p>The <code>Product</code> model is:</p>
  
  <pre><code>class Product(models.Model):
      product_id = models.AutoField(primary_key=True)
      product_name = models.CharField(max_length=50)
      description = models.TextField(blank=True)
  </code></pre>
  
  <p>The <code>Picture</code> model is:</p>
  
  <pre><code>class Picture(models.Model):
      product = models.ForeignKey(Product, related_name='pictures')
      path = models.ImageField(null=False, upload_to='product_pic')
      description = models.CharField(max_length=255, null=True, blank=True)
      main = models.BooleanField()
  </code></pre>
  
  <p>I write the serializer.py as follow:</p>
  
  <pre><code>class PictureSerializer(serializers.ModelSerializer):
      class Meta:
          model = Picture
          fields = ('path', 'description', 'main')
  
  class ProductSerializer(serializers.ModelSerializer): 
      pictures = PictureSerializer(many=True, required=False)
  
      class Meta:
          model = Product
          fields = ('product_id', 'product_name', 'pictures', 'description')
  </code></pre>
  
  <p>The view that I am using is:</p>
  
  <pre><code>class ProductEnum(generics.ListCreateAPIView):
      queryset = Product.objects.all()
      serializer_class = ProductSerializer
      permission_classes = (IsAuthenticated, )
  
      def post(self, request, format=None):
          serializer = ProductSerializer(data=request.DATA, files=request.FILES)
  
          if serializer.is_valid():
              serializer.save()
              return Response(serializer.data, status=status.HTTP_201_CREATED)
          return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p>I am registering it in the urls as:</p>
  
  <pre><code>url(r'^api/products/$', views.ProductEnum.as_view()),
  </code></pre>
  
  <p>The questions are:</p>
  
  <ul>
  <li>How could I test this POST api as <code>django-rest-framework</code> tells me that "Lists are not currently supported in HTML input"</li>
  <li>How to use JSON to POST a <code>Product</code> resources with multiple <code>Pictures</code>. OR I must use multipart parser.</li>
  <li>How to write cURL command? </li>
  </ul>