I need to update the object with its model form and passed the instance as described in the django doc <https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#the-save-method>. However I am having two problems when saving the form:
1. When I change the title and submit the form, the image field gets blank and it gives me an error that the image field is required. However when the image is changed and not the title, it does not give any error. 2. If everything works and submits the form, it creates a new snap object instead of updating the instance object. In the views I tried using both the obj.save() and obj.update(), but nothing helped. Please help me how to solve this problem. I will really appreciate your help Thank you. form: class SnapForm(forms.ModelForm): class Meta: model = Snap fields = ['title', 'description', 'image', 'upload_date'] view: def admin_snap_settings(request, snap_id): if not request.user.is_admin: return render(request, 'admin_login_invalid.html') else: instance = Snap.objects.get(id=snap_id) if request.user == instance.user: if request.method == "POST": form = SnapForm(request.POST, request.FILES, instance=instance) if form.is_valid(): form.save() return HttpResponseRedirect('/custom123user/admin/snapview') else: form = SnapForm(instance=instance) return render(request, 'admin_snap_settings.html', { 'form': form }) else: return render(request, 'wrong_user.html') -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAM4YLWKgohvAJNFV0SXNHdqmPSY9wEEN33n1FdH48d2ppWwNaQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.