开发者

self.request.form not iterable?

开发者 https://www.devze.com 2023-03-28 22:06 出处:网络
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

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

精彩评论

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