N
N
niakrisn2012-03-13 12:21:20
Python
niakrisn, 2012-03-13 12:21:20

Array of form data in python (Pyramid)

Hello.
Tell me how to get an analogue of the following in python:
HTML

<input type="text" name="someinput[]" value="1" />
<input type="text" name="someinput[]" value="2" />
<input type="text" name="someinput[]" value="3" />

PHP
$_POST['someinput'] - массив (1, 2, 3)

PS Form and full PHP code deliberately omitted.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
kamiram, 2012-03-13
@niakrisn

RTFM: Request -> MultiDict
request.POST.getall('foobar') - will return all values ​​named foobar

O
Oronro, 2012-03-13
@Oronro

And according to what law, these parameters should be aggregated into an array? This behavior is solely the lot of PHP and / or libraries involved in the processing of url parameters, nothing more.

G
gelas, 2012-03-13
@gelas

request.POST is a MultiDict,
you can get all values ​​by key like this request.POST.getall('someinput[]')

N
niakrisn, 2012-03-13
@niakrisn

Thank you all for the solution above.
Previously, I turned to the search engine and found only this option , it seemed too complicated, that's why I asked the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question