diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 5254db55..98ff1031 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2111,6 +2111,8 @@ class SQLFORM(FORM): field_id = groupby #take the field passed as groupby elif groupby and isinstance(groupby, Expression): field_id = groupby.first #take the first groupby field + while not(isinstance(field_id, Field)): # Navigate to the first Field of the expression + field_id = field_id.first table = field_id.table tablename = table._tablename if not any(str(f) == str(field_id) for f in fields):