I'm converting a PHP application over to django and one thing I took
for granted was PHPs conversion of inputs with the name "input[]" into
an array automatically.  Since django nor python seem to support that
conversion, what do people suggest for receiving 1 to N inputs on a
request.POST?

In my specific case, it's a shopping cart, so I want to let the user
add multiple items at the same time.  Eg, in HTML:

<select name="item[0]"><options......></select>
<select name="item[1]"><options......></select>

and ideally I could just do:
items = request.POST.get_list('item')

any ideas?  Should I just plan on doing:

pat = re.compile("^.+\[\d+\]$")
values = []
for name, value in request.POST.items():
   if(pat.search(name)):
       values.append(value)

Thanks.

Reply via email to