Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

<form 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')
like image 391
BillPull Avatar asked Mar 13 '26 19:03

BillPull


1 Answers

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

self.request.form.getlist('brands')
like image 98
BillPull Avatar answered Mar 16 '26 07:03

BillPull



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!