2

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.
  • 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.
  • Formsets will let you create multiple instances of bound or unbound forms: https://docs.djangoproject.com/en/1.5/topics/forms/formsets/ – Brandon Taylor Sep 17 '13 at 13:29
  • Another approach: https://github.com/gterzian/django_async – dani herrera Sep 17 '13 at 13:41
  • @danihp The problem with async in this case is that the user might stops filling the form and exits while at the same time the images are being uploaded. –  Sep 17 '13 at 14:31

1 Answers1

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)

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.

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

allcaps
  • 10,945
  • 1
  • 33
  • 54