Allether
Allether

Reputation: 52

Editing form with FileField removes the file

i have a ModelForm with dynamically generated fields . Everything works fine, but the editing. The input[type=file] loses its file and instead, it puts it in the <a href="/path/to/file"> called "currently". I think this is some kind of browser/HTML thing. When i submit the form i need those files in request.FILES.

This is how i define the initials of the file: self.initial[field_name2] = admins[i].contract

I wanted to handle it with Javascript, but it is not possible to change the value of input[type=file].

I would post some code, but it is kinda long so i prefer not to.

Upvotes: 1

Views: 53

Answers (1)

Libor B.
Libor B.

Reputation: 509

Don't use Javascript for this.

Try to make hidden HTML input field with filename as value. After POST check request.FILES first and if empty check request.POST with hidden field.

Upvotes: 1

Related Questions