Django: Binding uploaded files to a form

Something as trivial as uploading a file via a HTML form was recently changed. I know because a development branch update broke one of my websites.  That will teach me to test better! 🙂

The designers specify:

File data is handled separately to normal form data, so when your form contains a FileField and ImageField, you will need to specify a second argument when you bind your form.

An example:

f = ContactFormWithMugshot(request.POST, request.FILES)

This is a bit different from before when you would inject the FILES into the POST before passing it to the FileUploadForm.

Everything has to change a little bit to keep us on our toes.

Link here

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s