[Answered ]-Django – Form Not Saving Image on Form Submission

1👍

After debugging, I added the below to myaccount_edit.html and removed {{ form.image }}

<input type="file" id="upload-btn" name="image" type="submit" value="" accept="image/gif, image/jpg">

In my forms.py file,

image = forms.ImageField(required=True, label=_("image"), widget=forms.TextInput(attrs={'type': 'file', 'id': 'upload-btn', 'accept': 'image/gif, image/jpg'}))

TextInput wasn’t playing nice with ImageField since it’s I’m guessing i’m passing an image not text. This can be a common mistake maybe so it’s a small detail that can be missed. Thanks for the help!

Leave a comment