Mo J. Mughrabi
Mo J. Mughrabi

Reputation: 6997

re-uploading files when django form fails at some point

Am currently working with django and using the forms to render a form different fields. The problem am facing is that I have file field in the form and sometimes when submitting the form and a different field returns an error, the file field "value" disappear, which means must re-select the file again..

Is there a way to maintain the file even when the form returns an error? Any examples I can look at or anything that can help me?

Thanks

Upvotes: 0

Views: 91

Answers (1)

TigorC
TigorC

Reputation: 554

See https://github.com/un1t/django-file-resubmit

In Django project you have forms with FileField, ImageField. Everything works great, but when ValidationError is raised, you have to reselect all files and images again. It is kind of annoying. django-file-resubmit solves this problem. It works with FileField, ImageField and sorl.thumbnail.ImageField.

Upvotes: 1

Related Questions