Django UpdateView / ImageField issue: not returning new uploaded image Django UpdateView / ImageField issue: not returning new uploaded image django django

Django UpdateView / ImageField issue: not returning new uploaded image


If you are using UpdateView, you only need to add enctype="multipart/form-data" attribute to the form tag in your template. The rest will be handled by UpdateView class.


You need to save the form providing request.FILES:

if request.method == 'POST':    form = MyForm(request.POST, request.FILES)    if form.is_valid():        form.save()

And in your HTML form (since you have an <input type="file"> in the form):

<form method="POST" enctype="multipart/form-data">


just add to your template

 <form method="POST" enctype="multipart/form-data">