vishavjeet

singh.vishavjeet11@gmail.com

How Can Upload Files/Images using Django Form

Posted on June 02, 2021



# Create your views here.

def html_view(request):

   if request.method == 'GET':

       return render(request, "form.html")

dd = request.FILES['image_url']

 dd2 = request.FILES['image_url2']

 dd3 = request.FILES['image_url3']

 dd4 = request.FILES['image_url4']

 images = [dd, dd2, dd3, dd4]

 for image in images:

   ProductImage.objects.create('product'=request.POST['product'], 'image_url': image)

return render(request, "form.html")


Sign In for comment and like the post.