You should really read the django docs:
http://docs.djangoproject.com/en/dev/ref/request-response/
In your first case, the latter value will overwrite the first value,
so:
request.POST['test[]'] = 1 or POST = {'test[]': 1}
In your second case, you will just have one value:
request.POST['test[key]'] = 1 or POST = {'test[key]': 1}
You can't write objects into the name of the html input tag. Whatever
you write will be just a name. You can instead send objects like
lists, dictionaries of whatever you like in posts, but you don't want
people to input those, unless it's into a form that you validate
first. If you want to know about forms in django read about it in the
docs
http://docs.djangoproject.com/en/dev/topics/forms/
-Briel
On 19 Jan., 20:35, "Vinicius Mendes" <[email protected]> wrote:
> Is there in django something like the PHP POST subarrays?
>
> For example, if i do this in my form:
>
> <input type="text" name="test[]" value="0" />
> <input type="text" name="test[]" value="1" />
>
> and submit it, i will have the following data structure in my PHP POST:
>
> $_POST = array(
> 'test' => array(
> 0 => 0,
> 1 => 1
> )
> )
>
> In django, i think it can turn into:
>
> request.POST = {
> 'test': (0,1)
>
> }
>
> What means it is a dictionary with a tuple as the value of the 'test' key.
>
> Another case is this:
>
> <input type="text" name="test[key]" value="1" />
>
> Whet gives this in PHP:
>
> $_POST = array(
> 'test' => array(
> 'key' => 1
> )
> )
>
> What means the following in python:
>
> request.POST = {
> 'test': {
> 'key': 1
> }
>
> }
>
> Is there anything like this in django? I think it can make formsets much
> more easier to use, and eliminates the needing of the management_form.
>
> --------
>
> Vinícius Mendes
> Engenheiro de Computação
> Meio Código - A peça que faltava para o seu código!
> URLhttp://www.meiocodigo.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---