[Answered ]-How i can upload an image with CreateView on my post?

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

Leave a comment