If you're using a forms.FileField()
in a forms.Form
derived class, you can set:
class form(forms.Form):
file = forms.FileField(required=False)
If you're using a models.FileField()
and have a forms.ModelForm
assigned to that model, you can use
class amodel(models.Model):
file = models.FileField(blank=True, null=True)
Which you use depends on how you are deriving the form and if you are using the underlying ORM (i.e. a model).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…