django需要文件字段验证

时间:2016-10-18 09:43:45

标签: python django

使用django表单,其中我有两个文件上传字段,一个用于艺术家图像,另一个用于事件海报,这两个字段都是必需的。

class CreateEventStepFirstForm(forms.Form):
    event_title = forms.CharField(required = True, max_length=20, widget=forms.TextInput(attrs={
        'class' : 'custome-input promote-input', 
        'autocomplete' : 'off',
        'data-empty-message':'This field is required' 
    }))
    ticket_title = forms.CharField(required = True, max_length=225, widget=forms.TextInput(attrs={
        'class' : 'custome-input promote-input', 
        'autocomplete' : 'off',
        'data-empty-message':'This field is required' 
    }))
    artist_image = forms.FileField(required = True, widget=forms.FileInput(attrs={
        'class' : 'upload-img',
        'data-empty-message':'Please upload artist image, this field is required'
    }))
    event_poster = forms.FileField(required = True, widget=forms.FileInput(attrs={
        'class' : 'upload-img',
        'data-empty-message':'Please upload artist image, this field is required'
    }))

问题是所有字段都被正确验证,除了这两个文件字段,当我为artist_image和event_poster选择图像时,它不验证字段并给出“此字段是必需的”错误,即使我选择了两个图像。

1 个答案:

答案 0 :(得分:2)

您需要添加var confirmPopup = $ionicPopup.confirm({ title: 'Benvenuto!', template: 'Questa è la sezione che ti permette di guadagnare, condividendo l’App con tutti i tuoi contatti.' + '<br> Più amici effettueranno il download maggiori saranno i tuoi guadagni.' + '<br> Affrettati hai 30 giorni!' + '<br><br>' + '<a ui-sref="regulation">' + ' Il regolamento di partecipazione' + '</a>', okText: 'Annulla', okType: 'button-positive', cancelText: 'Accettare', cancelType: 'button-positive' } ); ,如下所示:

scrollView.scrollTo(0,100)