[Answered ]-How to write the corresponding "handle_uploaded_file" for the model field and form?


Why do you want to handle file attachments by yourself, django will do it for you.

Properties of FileField is here. I uesd it a few times before, i can not remember exactly butusing something as following must do the job…

First, create your form from related model:

class SomeFormWithFileForm(forms.ModelForm):
class Meta:
    model = SomeModel

then in your view, where you create your form instance,

form = SomeFormWithFileForm(request.POST, request.FILES)
if form.is_valid():

will do the trick.


Leave a comment