Django re-populate file fields on form error?

I currently have something like:

def my_view(request) if request.method == 'POST': form = MyForm(request.POST, request.FILES) if form.is_valid(): form.save() redirect() else: form = MyForm() return render_to_response('form.html', {'form': form}) 

If the form validation fails, all the fields associated with request.POST are re-populated, but the fields with the request. FILES are empty. Is this a known limitation of Django or is there something I can do to keep my file fields repeated?

+4
source share
1 answer

No, and this is not a Django problem like a browser problem. File fields cannot be filled with the initial value, otherwise it would be trivial to have a malicious form for downloading files from the user machine without their knowledge. The django user mailing list has a couple of topics:
http://groups.google.com/group/django-users/browse_thread/thread/14922dca454e3782/
http://groups.google.com/group/django-users/browse_thread/thread/f9fb21ddb4039b33/

+9
source

All Articles