I created a ModelForm with fields, title , file and content . Here file is FileField (). But I canβt name the save() method of this form for some reason. Therefore, I have to create one model object and assign cleared values ββto this object. Everything worked that FileField. The file is not saved. How can i fix this? Is this the right method to extract a filefield?
The form
class TestForm(forms.ModelForm): class Meta: model = Test fields = ('title','file', 'content',)
Views.py
form = TestForm(request.POST,request.FILES) if form.is_valid(): content = form.cleaned_data['content'] file = form.cleaned_data['file'] title = form.cleaned_data['title'] fax = Fax() fax.title = title fax.file = file fax.content = content fax.save()
The file is not saved here. How can i fix this? Any help would be appreciated!
source share