mbraak/django-file-form

How to append input files instead of replacing when the user picks the files again?

BismeetSingh opened this issue · 4 comments

I would like to allow the user to make file selection multiple times. I will show the selected file names in a table below and would like to add the newly selected file to the table.

There is a EditModelFormMultipleView view in the example project that does this.

class EditModelFormMultipleView(FileModelFormMultipleMixin, generic.UpdateView):

To see this working in the testproject. The url for creating is: http://localhost:8000/model_form_multiple For editing: http://localhost:8000/model_form_multiple/[id]

This example works with a ModelForm, but it should also be possible with a normal form. The trick is to override get_initial.

Also, is there a way to allow the user to remove the files?
Kinda like this:
image

Yes, the form has a 'delete' link.

This is from the example project:

Screenshot 2021-07-07 at 18 05 10

Couldnt figure out how to add multiple files. Solved using dropzone.js . Thanks anyway.