Form Value Array

2005-11-21 Thread Kevin
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

Re: Form Value Array

2005-11-21 Thread Adrian Holovaty
On 11/21/05, Kevin <[EMAIL PROTECTED]> wrote: > 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

Re: Form Value Array

2005-11-22 Thread Kevin
Unfortunately, I believe they're necessary. My exact code is a list of radio inputs, in template lanaguage and radio buttons use the input name as a way of grouping. My Models would be: class OptionSet(Model): name = CharField() class Option(Model): name = CharField option_set = Foreig

Re: Form Value Array

2005-11-22 Thread Adrian Holovaty
On 11/22/05, Kevin <[EMAIL PROTECTED]> wrote: > {% for option_set in item.get_options %} > > {{option_set.name}} > {% for option in option_set.get_choices %} > value="{{option.id}}"> {{option.name}} > {% endfor %} > {% endfor %} In this example, there's nothing forcing you to use the square brac

Re: Form Value Array

2005-11-22 Thread Kevin
I understand, and that's what I'm really doing at the moment, but I was just curious if there's a better way to retrieve these POST values than just: options = [] for name, value in request.POST.items(): if(name.startswith("option")): options.append(value)

Re: Form Value Array

2005-11-22 Thread Luke Plant
On Tue, 22 Nov 2005 10:37:08 -0800 Kevin wrote: > > I understand, and that's what I'm really doing at the moment, but I > was just curious if there's a better way to retrieve these POST > values than just: > > options = [] > for name, value in request.POST.items(): > if(name.startswith("opt

Re: Form Value Array

2005-11-22 Thread Kevin
I decided to try writing a generic array converter as a middleware: import re class ParamsMiddleware: patt = re.compile("^([a-zA-Z_]\w*)\[\(d*)\]$") LARGE_INT = 2**30 def process_request(self, request): if(request.POST): post = requ