Hi,

Here is the link to the Django docs where it is explained how to handle
multiple file uploads with FileInput. Try to use the example from the docs
as a starting point.

https://docs.djangoproject.com/en/5.0/topics/http/file-uploads/#uploading-multiple-files

Best regards,
--
Miroslav Milic


On Tue, Apr 2, 2024 at 7:20 PM arts maxwell Anderson <
arts.mawellanderson....@gmail.com> wrote:

> hello i have this error , i want to uppload multiple django image
> ValueError: FileInput doesn't support uploading multiple files.
> any one can help me
>
> class FormImages(ModelForm):
>     multiple_image= forms.ImageField(widget=forms.FileInput(attrs= {
> 'multiple': True}))
>
>     class Meta:
>
>         model = Images
>         fields=['multiple_image']
>
>
> #create prodcut in function
> def create_product(request):
>     form_image = FormImages()
>     form = FormCretaeProdcut()
>
>     if request.method == 'POST':
>         files = request.FILES.getlist('multiple_image')
>         form = FormCretaeProdcut(request.POST, request.FILES)
>         if form.is_valid():
>             product = form.save(commit=False)
>             product.save()
>             product.user = request.user
>             product.save()
>         for file in files :
>             Images.objects.create(product=product , images=file)
>     else:
>         form = FormCretaeProdcut()
>     return render(request, 'create_product.html', {'form':form, 'i_form':
> form_image})
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c5cf6e10-68a1-4ceb-915d-df489db9b863n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c5cf6e10-68a1-4ceb-915d-df489db9b863n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEOWdJUwkZPdAAqAbayEp%3DWhY5i9vrDk6fVk5VEjkTxkegj-%2Bw%40mail.gmail.com.

Reply via email to