# Multiple files upload via customized admin form

**URL:** <https://forum.djangoproject.com/t/multiple-files-upload-via-customized-admin-form/3995>\
**Category:** Using Django\
**Created:** [August 20, 2020, 12:27pm UTC](https://forum.djangoproject.com/t/multiple-files-upload-via-customized-admin-form/3995 "2020-08-20T12:27:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheraff0](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@sheraff0](https://forum.djangoproject.com/u/sheraff0)\
**Post date:** [August 20, 2020, 12:27pm UTC](https://forum.djangoproject.com/t/multiple-files-upload-via-customized-admin-form/3995/1 "2020-08-20T12:27:31Z")

</div>

Hi people!  
Tried to add multiple file upload field following [this example](https://www.quora.com/How-do-I-upload-multiple-files-at-a-time-in-Django-admin).  
The upload control appears and works properly - the problem is with form’s header - the `<form enctype="multipart/form-data"` attribute is omitted,  
so I get empty `request.FILE` in my custom `save_model` function.  
Only filenames are passed as text parameters, so I get in `request. __dict__ `:  
`"content_type": "application/x-www-form-urlencoded", ...`  
`"_post": <QueryDict: ... { "photos_multiple": ["image1.jpg", "image2.jpg"],`  
instead of:  
`"content_type": "multipart/form-data", ...`  
` "_files": <MultiValueDict: { "photos_multiple": [<InMemoryUploadedFile: image1.jpg (image/jpeg)>, <InMemoryUploadedFile: image2.jpg (image/jpeg)>] }>,`  
(example from a working non-customized admin form with a single file upload)  
I also have a working project config as an example, where  
`<form enctype="multipart/form-data"` is present, and the whole thing works!  
There seem to be no differences in this part of config.  
Has anybody an idea why the `<form enctype="multipart/form-data"` may be dropped and how can I reinforce it when necessary (like in this case).

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 20, 2020, 2:35pm UTC](https://forum.djangoproject.com/t/multiple-files-upload-via-customized-admin-form/3995/2 "2020-08-20T14:35:28Z")

</div>

I’d start by looking at what the browser is sending. You can use your browser’s developers tools to look at exactly what it’s sending back to the server. I would find it surprising if Django is doing anything at that layer to alter the data coming in, although I could see where it’s possible that it’s not handling the submission correctly.

At least, if you verify that the browser is sending the right data, you know that your form is being created and built correctly and you can focus on the incoming side. However, if the data isn’t being submitted correctly, then it’s more likely that your form isn’t built correctly.

(The idea here is to narrow down what you need to look at to one of those two possibilities.)

Ken

---

<div class="post-metadata">

**Author:** ![sheraff0](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@sheraff0](https://forum.djangoproject.com/u/sheraff0)\
**Post date:** [August 20, 2020, 3:01pm UTC](https://forum.djangoproject.com/t/multiple-files-upload-via-customized-admin-form/3995/3 "2020-08-20T15:01:41Z")

</div>

Well, it doesn’t tell much…  
The request and the form structure are correct, apart form missing  
**enctype="multipart/form-data"**

> **Request**
>
> Request URL: http://0.0.0.0:8000/admin/product/product/1e9ceca6-ee73-4d34-b51b-39f95d34f8ae/change/  
> Request Method: POST  
> Status Code: 302 Found  
> Remote Address: 0.0.0.0:8000  
> Referrer Policy: no-referrer-when-downgrade  
> Cache-Control: max-age=0, no-cache, no-store, must-revalidate  
> Content-Language: ru  
> Content-Length: 0  
> Content-Type: text/html; charset=utf-8  
> Date: Thu, 20 Aug 2020 14:53:50 GMT  
> Expires: Thu, 20 Aug 2020 14:53:50 GMT  
> Location: /admin/product/product/1e9ceca6-ee73-4d34-b51b-39f95d34f8ae/change/  
> Server: Werkzeug/0.14.1 Python/3.7.9  
> Set-Cookie: messages=“551bb16c6ad0e6b82b80c7bcb991727247636866$[[”\_\_json\_message"\0541\05425\054"\u041f\u0440\u043e\u0434\u0443\u043a\u0442 (\u043c\u043e\u0434\u0435\u043b\u044c) \"\<a href=\"/admin/product/product/1e9ceca6-ee73-4d34-b51b-39f95d34f8ae/change/\"\>\u041f\u043e\u0440\u0442\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0430\u043a\u0443\u0441\u0442\u0438\u043a\u0430 3 (\u0430\u043a\u0443\u0441\u0442\u0438\u043a\u0430)\" \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430 \u043d\u0438\u0436\u0435."]]"; HttpOnly; Path=/; SameSite=Lax  
> Vary: Accept-Language, Cookie  
> X-Frame-Options: DENY  
> X-XSS-Protection: 1; mode=block  
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,_/_;q=0.8,application/signed-exchange;v=b3;q=0.9  
> Accept-Encoding: gzip, deflate  
> Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7  
> Cache-Control: max-age=0  
> Connection: keep-alive  
> Content-Length: 3651  
> Content-Type: application/x-www-form-urlencoded  
> Cookie: djdt=hide; csrftoken=aUtjZ4jaPEevOSAJMVtLQjir94WkamgZYHHEVikyWZ6rInYlKz4WsQYDnu1Fy9wN; sessionid=j95v32tzrie9p2c7yvlrw7g1pbctgdw2  
> Host: 0.0.0.0:8000  
> Origin: [http://0.0.0.0:8000](http://0.0.0.0:8000)  
> Referer: [http://0.0.0.0:8000/admin/product/product/1e9ceca6-ee73-4d34-b51b-39f95d34f8ae/change/](http://0.0.0.0:8000/admin/product/product/1e9ceca6-ee73-4d34-b51b-39f95d34f8ae/change/)  
> Upgrade-Insecure-Requests: 1  
> User-Agent: Mozilla/5.0 (X11; Linux x86\_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 OPR/70.0.3728.106  
> csrfmiddlewaretoken: Z3zEHizZifIZLs5rPKVqbyet9gPeVT76NQNZDwAnpAAVFXt3NowBN5UFnGUzjGnU  
> name: Портативная акустика 3 (акустика)  
> subcategory: 18c05a40-af73-4f0c-b68e-09f4875409ce  
> price\_before:  
> price: 119.77  
> order\_number: 4  
> active: on  
> description:
> 
> …
> 
>   
> Product\_product\_images-TOTAL\_FORMS: 6  
> Product\_product\_images-INITIAL\_FORMS: 6  
> Product\_product\_images-MIN\_NUM\_FORMS: 0  
> Product\_product\_images-MAX\_NUM\_FORMS: 1000  
> Product\_product\_images-0-id: 4540  
> Product\_product\_images-0-product: 1e9ceca6-ee73-4d34-b51b-39f95d34f8ae  
> Product\_product\_images-0-productimage: 2abda7ed-93d8-402c-986c-50f5534737cc  
> Product\_product\_images-1-id: 4597  
> Product\_product\_images-1-product: 1e9ceca6-ee73-4d34-b51b-39f95d34f8ae  
> Product\_product\_images-1-productimage: 1f9bc900-9d2c-47d7-9e34-c98ccccf7229  
> Product\_product\_images-2-id: 4541  
> Product\_product\_images-2-product: 1e9ceca6-ee73-4d34-b51b-39f95d34f8ae  
> Product\_product\_images-2-productimage: d98aac7f-3b42-4c27-820e-a40b42a8908a  
> Product\_product\_images-3-id: 4542  
> Product\_product\_images-3-product: 1e9ceca6-ee73-4d34-b51b-39f95d34f8ae  
> Product\_product\_images-3-productimage: 1675adea-50b7-474f-98b6-4f28daddab46  
> Product\_product\_images-4-id: 4543  
> Product\_product\_images-4-product: 1e9ceca6-ee73-4d34-b51b-39f95d34f8ae  
> Product\_product\_images-4-productimage: 8cc9c164-9c1e-4a51-b288-6db3cf7d5b76  
> Product\_product\_images-5-id: 4544  
> Product\_product\_images-5-product: 1e9ceca6-ee73-4d34-b51b-39f95d34f8ae  
> Product\_product\_images-5-productimage: 80647421-882a-4b49-8290-75f1000f8b83  
> Product\_product\_images- **prefix** -id:  
> Product\_product\_images- **prefix** -product: 1e9ceca6-ee73-4d34-b51b-39f95d34f8ae  
> Product\_product\_images- **prefix** -productimage:  
> photos\_multiple: куго.jpg  
> photos\_multiple: сегвеи.jpg  
> \_continue: Сохранить и продолжить редактирование  
> This text will be hidden

---

<div class="post-metadata">

**Author:** ![fedmolac](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/fedmolac/32/2863_2.png) [@fedmolac](https://forum.djangoproject.com/u/fedmolac)\
**Post date:** [December 18, 2020, 4:42pm UTC](https://forum.djangoproject.com/t/multiple-files-upload-via-customized-admin-form/3995/4 "2020-12-18T16:42:39Z")

</div>

Can you pls share your code to upload the multiple files to admin page. I am new to django and stuck there. Thanks
