title: How to upload multiple files with django-rest-framework
body: <p>I am trying to upload a file using django-rest-frame, which works when uploading a single file. But when I upload multiple files, only the last file will be saved. How can I save all the files?</p>
  
  <p>Python 3.6.2，
  Django 2.2.3
  djangorestframework 3.10.1</p>
  
  <p>Below is my code</p>
  
  <p>the vue：</p>
  
  <pre><code>&lt;template&gt;
      &lt;input id="upload_file" type="file" multiple @change="v_upload_files"/&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
    export default {
      data() {
        return {
          fileList: []
        };
      },
      methods: {
          v_upload_files(e) {
              let files = e.target.files;
              let formData = new FormData();
              for (let i = 0;i &lt; files.length;i++) {
                  formData.append(`file${i}`, files[i])
                  // formData.append('file', files[i])
              }
              let url = '/upload/';
  
              axios.post(url, formData)
  }
    }
  
  }
  &lt;/script&gt;
  
  </code></pre>
  
  <p>models.py</p>
  
  <pre class="lang-py prettyprint-override"><code>class File(models.Model):
      file = models.FileField(blank=False, null=False)
  
      def __str__(self):
          return self.file.name
  
  </code></pre>
  
  <p>serializers.py</p>
  
  <pre class="lang-py prettyprint-override"><code>from rest_framework import serializers
  from .models import File
  
  
  class FileSerializer(serializers.ModelSerializer):
  
      files = serializers.ListField(child=serializers.FileField())
  
      class Meta:
          model = File
          fields = "__all__"
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>from rest_framework.parsers import MultiPartParser
  from rest_framework.response import Response
  from rest_framework.views import APIView
  from rest_framework import status
  from .serializers import FileSerializer
  
  class FileUploadView(APIView):
      parser_class = (MultiPartParser,)
  
      def post(self, request, *args, **kwargs):
  
          altered_request_data = request.data.copy()
          in_memory_upload_files_list = [value for value in request.FILES.dict().values()]
          print(request.FILES.dict().values())
          altered_request_data.setlist('files', in_memory_upload_files_list)
          file_serializer = FileSerializer(data=altered_request_data)
          print(file_serializer)
          print(file_serializer.is_valid())
          if file_serializer.is_valid():
              file_serializer.save()
              print(file_serializer.data)
              return Response(file_serializer.data, status=status.HTTP_201_CREATED)
          else:
              return Response(file_serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p><strong>upload 2 files</strong></p>
  
  <pre><code>FileSerializer(data=&lt;QueryDict: {'file{i}': [&lt;InMemoryUploadedFile: 20190724_BRCA_report.xlsx (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)&gt;, &lt;InMemoryUploadedFile: 20190724_DMD_report.xlsx (application/vnd.openxmlformats-officedocument.spread
  sheetml.sheet)&gt;], 'files': [&lt;InMemoryUploadedFile: 20190724_DMD_report.xlsx (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)&gt;]}&gt;):
      id = IntegerField(label='ID', read_only=True)
      files = ListField(child=FileField(), write_only=True)
      file = FileField(max_length=100)
  Bad Request: /upload/
  
  </code></pre>
  
  <p>in Browser it return</p>
  
  <pre><code>{"file":["No file was submitted."]}
  </code></pre>