[Flask] Access form data in view function

Corey Boyle coreybrett at gmail.com
Thu Apr 21 08:21:15 EDT 2016


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
>


More information about the Flask mailing list