How to use django rest framework to access form-data with multiple files with file name for each file separately?

Requirement: Upload multiple files with custom file name for each file Frontend: React

I use django rest api and want to get each file with associate data like custom file name. But I don't have idea to how to do this. When I receive api request with form-data that only contains files then it is okay to access these data using request.FILES/ It is also okay to receive single file with its' file name because in form data we can set one key(file) for file and another key(text) for file name.

But how it is possible to use multiple files with file name for each file. Frontend is not designed/developed by me. So tried with curl/Postman to simulate the frontend request. But no idea about the real implementation of the backend and frontend. So no way to test this kind of request using Postman/Curl

Just found a way: How to write a curl with named multipart body

Thanks to above question, I set file name with the file in curl request as below(added filename attribute). I could successfully simulate something I wanted. Still don't know that this will be compatible with frontend request.

curl --location --request POST "" --form 'file=@"/media/Michel.pdf";filename="Mich"' --form 'file=@"/media/Hedra_Mel.pdf";filename="Mel"'


Константы Python: Улучшение управляемости вашего кода

Современный Python: начинаем проект с pyenv и poetry

Настройка проекта Python — виртуальные среды и управление пакетами

Использование requests в Python — тайм-ауты, повторы, хуки

Понимание декораторов в Python

ProcessPoolExecutor в Python: полное руководство

map() против submit() с ProcessPoolExecutor в Python

Понимание атрибутов, словарей и слотов в Python

Полное руководство по slice в Python

Выпуск Django 4.0

Безопасное развертывание приложения Django с помощью Gunicorn, Nginx и HTTPS

Автоматический повтор невыполненных задач Celery

Django REST Framework и Elasticsearch

Докеризация Django с помощью Postgres, Gunicorn и Nginx

Асинхронные задачи с Django и Celery

Релизы безопасности Django: 3.2.4, 3.1.12 и 2.2.24

Выпуски исправлений ошибок Django: 3.2.3, 3.1.11 и 2.2.23

Эффективное использование сериализаторов Django REST Framework

Выпуски безопасности Django: 3.2.2, 3.1.10 и 2.2.22

Выпущенные релизы безопасности Django: 3.2.1, 3.1.9 и 2.2.21

View all tutorials →