You are here: Home Blog Django newforms file upload

Django newforms file upload

by Dan Fairs last modified Oct 28, 2007 05:57 PM
Existing documentation about updating request.POST with request.FILES is now obsolete.

There are several places documenting that to get newforms working with file uploads, you have to do something like this (where NewformsClass is, you guessed it, a newforms class):

 new_data = request.POST.copy()  
 new_data.update(request.FILES) 
 form = NewformsClass(new_data)

This is now out-of-date, and has been simplified to the following:

form = NewformsClass(request.POST, request.FILES)

Much neater.

Filed under:
Add comment

You can add a comment by filling out the form below. Plain text formatting.