i have a form that is like:
class tesoffcliForm(forms.Form)
image = forms.FileField(label='Image', required = False)
art_gen = forms.CharField(label='test ', required = False ,widget = forms.Textarea())
the view is:
def testrendering(request):
form = tesoffcliForm()
number = range(100)
return render(request, 'polls/test.html', {'form':form,
'range':number, })
the template is:
{% for a in range %}
{% for field in form %}
{{ field.label }} {{ field }}
{% if forloop.counter|divisibleby:"2" %}
<br><br>
{% endif %}
{% endfor %}
the view for get the data is very easy:
def get_data(request):
art = request.POST.getlist('art_gen')
image = request.FILES.getlist('image')
the list generated are:
art = a list of 100 lines, where if i have no imput in the list i find ' '
image = a list with only the file that i have decide to upload.
how can i have also an empty folder in the image list??? for example
image = [file obg, ' ' , file obj 2, etc....]
if i can't do this i have no corrispondance between art and image when i save in the database
Thanks for your help