I have form with a textbox and filefield in django. It should let the use either paste the text into that box or upload a file. If the user has pasted the text into the box, I needn’t check the fileField.
How do I make the forms.FileField() optional?
If you’re using a
forms.FileField()in aforms.Formderived class, you can set:If you’re using a
models.FileField()and have aforms.ModelFormassigned to that model, you can useWhich you use depends on how you are deriving the form and if you are using the underlying ORM (i.e. a model).