You cannot put expressions in grid in place of fields. On Monday, 9 September 2013 18:44:18 UTC-5, dam...@gmail.com wrote: > > Hi, > > I'm using web2py 2.6.0. test. > > on sqlhtml.py line 1916: > > columns = [f for f in fields if f.tablename in tablenames] > > > when add field count, count not attribute 'tablename' and: > > AttributeError: 'Expression' object has no attribute 'tablename' > > My code: > submenus = db.menus.with_alias('menusoptions') > query = (db.menus.parent_id == 0) > count = submenus.id.count() > > table = SQLFORM.grid(query, > fields = [ > db.menus.title, > count, > ], > left=submenus.on(db.menus.id == > submenus.parent_id), > groupby=db.menus.title, > ) > --- > I think that de problem is field count, this, not have attribute tablename > > fiel count is: Expression: COUNT(menusoptions.id) > > > when: > submenus = db.menus.with_alias('menusoptions') > query = (db.menus.parent_id == 0) > count = submenus.id.count() > menus = db(query).select(db.menus.id, > count,left=submenus.on(db.menus.id == submenus.parent_id), > groupby=db.menus.id ) > work fine. > > > Thanks. > >
-- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.