Using Flask, I'm trying to create a simple list of values POSTed from a web page. The only POSTed data will be the values associated with 1 to as many as 60 checkboxes, all named "state". The following code only returns the first value in the list, but all values are required for further processing:
[email protected]('/doCheck', methods = ['POST'])
def doCheck():
d = request.form['state']
I tried using the method .getList() like so:
d = request.form.getList('state')
return d
...but get this error: AttributeError: 'ImmutableMultiDict' object has no attribute 'getList'
So I tried this instead:
d = getList(request.form)
return d
...and got the error NameError: name 'getList' is not defined.
That seems to indicate I should include a method or class but which one?
The method is getlist
, without a capital L:
states = request.form.getlist('state')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With