Instead of {'db.Project': query}, it should be {'Project': query}.
db.Project is a Table object, but "Project" is the table name.
Anthony
On Friday, January 8, 2016 at 2:12:17 PM UTC-5, Ron Chatterjee wrote:
>
> Responding to this old post.
>
>
> query = db.Project.created_by == auth.user_id;
>
> if_author = lambda row: (row.created_by==auth.user_id)
> #grid = SQLFORM.smartgrid(db.Project,
> constraints={'db.Project':query},editable=if_author,deletable=if_author,details=True,create=False,csv=False)
>
> #doesn't work
> grid =
> SQLFORM.grid(query,editable=if_author,deletable=if_author,details=True,create=False,csv=False)#works
>
>
> why?
>
>
>
> On Tuesday, July 16, 2013 at 6:15:44 AM UTC-4, Massimo Di Pierro wrote:
>>
>> Answered in other thread...
>>
>> SQLFORM.grid(query) OK
>> SQLFORM.smartgrid(table) OK
>> SQLFORM.smartgrid(query) WRONG!
>> SQLFORM.smartgrid(table, contraints={'tablename':query}) OK
>>
>> On Tuesday, 16 July 2013 01:03:58 UTC-5, Sarbjit singh wrote:
>>>
>>> I am doing the following steps :
>>>
>>> >>> db = DAL('sqlite://storage.db')
>>> >>> db.define_table('person', Field('name'), Field('country'))
>>> >>> db.person.insert(name='John', country='UK')
>>> >>> db.person.insert(name='David', country='US')
>>> >>> query = db.person.name=="David"
>>>
>>> >>> SQLFORM.smartgrid(query)
>>>
>>> Traceback (most recent call last):
>>> File "<console>", line 1, in <module>
>>> File "....\gluon\sqlhtml.py", line 2459, in
>>> smartgrid
>>> if request.args(len(args)) != table._tablename:
>>> AttributeError: 'Query' object has no attribute '_tablename'
>>>
>>> While if I try the below code, it works fine.
>>>
>>> >>> db(query).select()
>>>
>>> Can some one please point me why this query is not working with
>>> "smartgrid".
>>>
>>> Thanks
>>> Sarbjit
>>>
>>>
>>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.