[Answer]-How to save path to image when I create object using forms

1👍

✅

the file data isn’t in request.POST it’s in request.FILES

https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handling-uploaded-files-with-a-model

Change your function to something like

def add_instance(request):
   if request.POST:
      form=InstanceForm(request.POST, request.FILES)
      if form.is_valid():
         new_instance=form.save()
   else:
      form=InstanceForm()

   locals().update(csrf(request))
   return render_to_response(...)

Leave a comment