[英]Django and multi-image upload form

I have this form that includes around 25 inputs on the same. It includes a main image input and the rest are some text inputs or drop down menus.


The problem is that I also need the user to upload multiple images. I was thinking of doing it on the next page itself.


I have 2 questions:


  • What is the best way for adding this multiple image upload form to the current form? Not related to Django, more related to the structure of the form.
  • 将这个多图像上传表单添加到当前表单的最佳方式是什么?与Django无关,更与表单的结构有关。
  • What is the best way of adding a multiple image/file to work correctly with Django? Any libraries or modules for such a job or any manual way to do it.
  • 添加多个映像/文件以正确使用Django的最佳方式是什么?用于这种工作的任何库或模块或任何手工方式。

1 个解决方案



With formsets you allow the user to create several images at once. To create a formset out of an ImageForm you would do:


>>> from django.forms.formsets import formset_factory
>>> ImageFormSet = formset_factory(ImageForm)

And Django comes with an optional “form wizard” application that splits forms across multiple Web pages. It maintains state in one of the backends so that the full server-side processing can be delayed until the submission of the final form.




粤ICP备14056181号  © 2014-2020