fields should be a list of Field objects, not field names. Anthony
On Friday, September 27, 2013 11:17:57 AM UTC-4, Gael Princivalle wrote: > > Hi. > > I want to make a simple SQLFORM.grid test. I have one table. I've tried to > make a lot of changes, but it don't works. With this code the ticket is > 'str' object has no attribute 'tablename'. > > Someone can help me ? > > MY DB: > db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) > db.define_table('products', > Field('code', unique=True), > Field('description'), > Field('producer'), > Field('path_pdf')) > db.products.id.writable = db.products.id.readable = False > > IN MY CONTROLLER > def test(): > """I want all rows""" > query=db.products.id>0 > fields = > ('products.code','products.description','products.producer','products.path_pdf') > headers = {'products.code': 'Product code', > 'products.description': 'Description', > 'products.producer': 'Brand', > 'products.path_pdf': 'Catalogue' } > default_sort_order=[db.products.code] > form = SQLFORM.grid(query=query, fields=fields, headers=headers, > orderby=default_sort_order, > create=False, deletable=False, editable=False, > maxtextlength=64, paginate=25) > return dict(form=form) > > IN MY VIEW test.html: > {{extend 'layout.html'}} > {{=form}} > -- 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.