title: upload images as raw data in django rest framework
body: <p>I am using Django-rest Framework for a project in which I am uploading the images to amazon s3 from my local system. This I am doing using the Html form which works fine. <a href="https://i.stack.imgur.com/OlYYc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OlYYc.png" alt="enter image description here"></a></p>
  
  <p>This is the model image.</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Image(models.Model):
      image_meta = models.ForeignKey('Image_Meta',on_delete=models.CASCADE,)
      image = models.ImageField(upload_to='images-data')
      order = models.IntegerField()
      version = models.CharField(max_length=10)
  </code></pre>
  
  <p>But when I try to upload the image as <strong>raw data</strong> I get an error. <a href="https://i.stack.imgur.com/BJfqX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BJfqX.png" alt="enter image description here"></a></p>
  
  <p>I want to know how can I do that. I tried to enter the location of the file in the local system for image field without any success.</p>
  
  <p>What am I doing wrong here or am I missing something here?</p>
  
  <p>The views.py file is below:</p>
  
  <pre><code>class ImageList(APIView):
      parser_classes = (JSONParser, )
  
      def get(self, request, format=None):
          images = Image.objects.all()
          serializer = ImageSerializer(images, many=True)
          return Response(serializer.data)
  
      def post(self, request, format=None):
          serializer = ImageSerializer(data=request.data  , files=request.FILES)
          print serializer
          if serializer.is_valid():
              serializer.save()
              return Response({'received data': request.data})
          return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p><strong>serializer.py</strong></p>
  
  <pre><code>class ImageSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = Image
          field = ('id', 'image_path' , 'order' , 'version')
  </code></pre>