In Flask 0.8, I know I can access individual form fields using form.fieldname.data, but is there a simple way of iterating over all the form fields? I’m building an email message body, and I’d like to loop over all the fields and create a fieldname/value entry for each, as opposed to manually building it by naming each field and appending.
In Flask 0.8, I know I can access individual form fields using form.fieldname.data ,
Share
I suspect that your are using WTForms.
You can iterate over form data:
You can iterate over all form fields: