I am pretty new to Django and I met a problem in handling image upload using ModelForm. My model is as following:
class Project(models.Model):
name = models.
You shouldn't need to set the newproject.photo
to request.FILES['photo']
(actually this right here probably breaks your code). Just save the addprojectform
with addprojectform.save()
instead of newproject = addprojectform.save(commit=False)
. See more info here: https://docs.djangoproject.com/en/1.5/topics/http/file-uploads/#handling-uploaded-files-with-a-model