I have this weird problem in Django.
I have a form with several text fields and a ImageField. In an edit view, I want the form to be prepopulated with values from an instance, retrieved from the database.
The below code seems to work:
form = UserForm(request.POST or None, instance=instance)
It prepopulates my form with the text fields. The ImageField is also prepopulated, but no matter what new image I choose, it doesn't update after the submission of the form.
I've tried:
form = UserForm(request.POST or None, request.FILES, instance=instance)
which, for some reason, causes every field in the form to be empty with the exception of the ImageField, which I can now change.
What I want to achieve is: the text fields to be prepopulated, as well as the ImageField. I should be able to change the ImageField.
Any thoughts on that?