开发者

self.request.form not iterable?

Hello I am making a form in HTML and python and I am having a problem with processing the arguments

the problem comes in this section

<f开发者_开发知识库orm method="POST">
  <input type="checkbox" name="brands" value="1" />
  <input type="checkbox" name="brands" value="2" />
</form>

and in the python I am using a self.request.form object to retrieve the arguments the problem is if I do something like

for b in brands:
   print b

it will just print out 1 even if both of them are in the self.request.form object

USING Werkzeug Framework

ANSWERED: I found you can retrieve a list of the same named inputs using this syntax

self.request.form.getlist('brands')


I found you can retrieve a list of the same named inputs using this syntax

self.request.form.getlist('brands')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜