I have read the documentation several times, but I am still confused. When you specify a model in Django, you can specify the file's destination. However, in the documentation, they go on a great deal about handling the write to disk manually. My question is: Is it better to just say form.save()
or to write a file handler with a hardcoded(?) path. form.save()
has been flakey for me.
Asked
Active
Viewed 1,267 times
0

SapphireSun
- 9,170
- 11
- 46
- 59
1 Answers
4
Calling the form's save method should work just fine, assuming you are using a forms.ModelForm
subclass. Some things to note.
- Make sure to properly set the form's enctype in the template
Be sure the view that handles the form checks for files
form=MyModelForm(data=request.POST, files=request.FILES)
When you say form.save()
has been flaky, what do you mean?

czarchaic
- 6,268
- 29
- 23
-
I am saving a modelform but for some reason it's not showing up :( – SapphireSun Dec 26 '09 at 19:56
-
I think it was mostly my fault. I'm trying to get it to work when the submitted form has errors. – SapphireSun Dec 31 '09 at 21:53