Reputation: 66071
How do I get a list of all the field objects (e.g. gluon.dal.Field
) in a table?
The following
db.customer.fields
just returns a list of strings which are the field names.
Upvotes: 4
Views: 2265
Reputation: 66071
Okay I see that fields are defined as attributes of the table class (gluon.dal.Table
). The table class has a __getitem__
method defined which allows indexing by attribute name (as python allows).
Therefore I can get a list of field objects by using a list comprehension:
[db.customer[fieldname] for fieldname in db.customer.fields]
Upvotes: 1