In addition to 'getvalue', the following methods may be used to access form data by field name:
- form.getfirst Returns the first value found for a field by the given name
- form.getlist Returns a list of all values found for a field by the given name. If no values are found, it returns an empty list.
In a case where each field name is unique, all three methods will return the same results. So the following will return the same data:
The method 'getlist', however, will return a list of values. The others will simply return a string.
name = form.getvalue('name') name = form.getfirst('name') name = form.getlist('name')