I\'m using jquery form plugin http://jquery.malsup.com/form/#getting-started to upload images through ajax. When I try to upload it shows the model has no attribute _committ
Instead of g.background = form
in the else branch, try
try:
g = BackgroundModel.objects.get(user=request.user)
except BackgroundModel.DoesNotExist:
data = form.save(commit=False)
data.user = request.user
data.save()
else:
g.background = form.save(commit=False).background
g.save()
# or
BackgroundModelForm(request.POST, request.FILES, instance=g).save()
Only a value of accepted types could be assigned to corresponding field of a model instance.
models.ImageField here accepts