Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Howto use Django class based UpdateViews with FileFields

I have a simple model containing a FileField among others. When I use a class based UpdateView It is possible to modify all fields of the model and changes are saved to the database on submit.The only exception to this is the FileField, while it is displayed as part of the form, and I can choose I file I want to upload nothing is saved.

Question: How can I use FileFields in class-based UpdateViews, is there specific code required to handle those fields?

like image 230
circus Avatar asked Apr 01 '12 12:04

circus


1 Answers

Make sure your form is declared like so:

<form enctype="multipart/form-data" method="post" action="/foo/">
like image 114
Timmy O'Mahony Avatar answered Sep 21 '22 12:09

Timmy O'Mahony