2π
β
To add a file field to your form you use the FileField
from the forms
module like image = forms.FileField()
If you want to modify the widgets of your form fields inside the form, just add the widgets
property to the Meta class. Like this:
class PostForm(Form):
image = FileField()
class Meta:
fields = ('title', 'text')
widgets = {
'title': forms.TextInput(attrs={'what': 'ever'}),
}
π€Cory Madden
Source:stackexchange.com