[Flask] Access form data in view function

Corey Boyle coreybrett at gmail.com
Thu Apr 21 09:07:49 EDT 2016


Paste your latest HTML into a pastebin so we can see it.

On Thu, Apr 21, 2016 at 8:33 AM, Alex Hall <ahall at autodist.com> wrote:
> No, but that was a good idea. It gave me all the built-in functions, and I
> saw "values" among them. When I print request.form.values, I see only
> 'orderNumber' (my text field) and u''. I should see at least my checkbox,
> which I made sure to uncheck the first time and check the second time, but I
> don't. I also double checked my template, and the source of the webpage in
> Firefox, but all elements are definitely inside the form element. Does
> "values" do something other than what I'm thinking, or does this mean my
> form is somehow missing the rest of its fields?
>
> On Thu, Apr 21, 2016 at 8:21 AM, Corey Boyle <coreybrett at gmail.com> wrote:
>>
>> Have you tried using Python's dir builtin on the form object inside
>> the request object?
>>
>> On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall <ahall at autodist.com> wrote:
>> > Hello all,
>> > Further to my question about multiple select fields yesterday, how does
>> > a
>> > view function access form data in general? I know I use the global(?)
>> > request object's "form" property, but beyond that I'm not sure. I can
>> > access
>> > StringField values (I'm using WTF) by using request.form.fieldID. But
>> > single
>> > select fields, multiple select fields, the status of checkboxes or radio
>> > buttons, and so on I can't work out or find online. One resource said,
>> > for
>> > checkboxes, to use request.form.getlist("checkboxID"), but that gave me
>> > an
>> > empty list despite that checkbox being checked. What am I missing? I
>> > know
>> > people usually use validators, but I need the values and statuses of
>> > elements in my form-processing view function because I'm dynamically
>> > constructing an SQL query based on the form's information.
>> >
>> > --
>> > Alex Hall
>> > Automatic Distributors, IT department
>> > ahall at autodist.com
>> >
>> > _______________________________________________
>> > Flask mailing list
>> > Flask at python.org
>> > https://mail.python.org/mailman/listinfo/flask
>> >
>
>
>
>
> --
> Alex Hall
> Automatic Distributors, IT department
> ahall at autodist.com


More information about the Flask mailing list