model:
class Logo(models.Model):
media = models.ImageField(upload_to='uploads')
def __unicode__(self):
return self.media.url
view:
class LogoEdit(UpdateView):
model = Logo
template_name = 'polls/logo-edit.html'
success_url = '/polls/logos/'
def form_valid(self, form):
pdb.set_trace()
template:
<form id="my_form" action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes" />
</form>
selecting new image:
debug view:
existing image:
(Pdb) self.object
<Logo: media/uploads/DSCN0844.JPG>
form with new selected image (DSC_0021.JPG):
(Pdb) test = form.save()
(Pdb) test
<Logo: media/uploads/DSCN0844.JPG>
As you can see the original image remains in form!