[Answer]-Query Error when Saving Image ModelForm in Django

1👍

Why are you saving it to the model class directly? Try:

form = User_ImageForm(request.POST, request.FILES)
if form.is_valid():
    im = form.save()
    HttpResponseRedirect("/accounts/profile")
👤CJ4

0👍

You don’t need to following lines.

im = User_Image(request.POST, request.FILES)
im = im.save()

Enough to save the form,

.....
if form.is_valid():
   form.save()
   HttpResponseRedirect("/accounts/profile")
.....

Leave a comment