Django和多图像上传表单

[英]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.

我有这个表格包含了大约25个相同的输入。它包括一个主图像输入,其余是一些文本输入或下拉菜单。

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 个解决方案

#1


1  

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

使用formset,您允许用户同时创建多个图像。要从ImageForm中创建一个窗体,您需要:

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

https://docs.djangoproject.com/en/1.5/topics/forms/formsets/

https://docs.djangoproject.com/en/1.5/topics/forms/formsets/

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.

Django提供了一个可选的“表单向导”应用程序,可以在多个Web页面上分割表单。它在一个后端中维护状态,以便可以将完整的服务器端处理延迟到提交最终表单。

https://docs.djangoproject.com/en/1.5/ref/contrib/formtools/form-wizard/

https://docs.djangoproject.com/en/1.5/ref/contrib/formtools/form-wizard/

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2013/09/17/f0ffa616caa9aa89f90c9daa600d9233.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告