Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save html array with Django forms?

Tags:

django-forms

I have some html form with fields like this:

<input type="text" name="input[]">
<input type="text" name="input[]">
<input type="text" name="input[]">
<input type="text" name="input[]">

How i can save this form with django forms?

like image 375
inlanger Avatar asked Apr 04 '11 17:04

inlanger


1 Answers

use QueryDict.getlist

inputs = request.POST.getlist('input[]')

it's not mandatory to put [] in the name

<input type="text" name="input">...

like image 78
manji Avatar answered Sep 23 '22 22:09

manji