The difference between a grid and a smartgrid is that the former can 
represent the result of a join, the latter does not (even if it create 
links to linked tables). Your constraint creates a join. The output of the 
join is not like row[i].first_name but row[i].auth_user.first_name. The 
grid fails because does not know how to deal with this. I think the problem 
specifically arises when trying to represent references.

This can be improved.

On Monday, 17 June 2013 18:36:24 UTC-5, André Kablu wrote:
>
> Hi all,
>
> I am trying to create a grid with a query for auth_user table doing this:
>
> def controller1():
>
>     query = ((db.auth_user.id == db.auth_membership.user_id) &
>              (db.auth_membership.group_id == 1))
>     grid = SQLFORM.smartgrid(db.auth_user,
>                              constraints=dict(auth_user=query
>                                               ),
>                              deletable=False,
>                              editable=True,
>                              create=False,
>                              csv=False)
>     return dict(grid=grid)
>
> I am doing a constraint to filter only for members of group 1 in list... 
> and it is working fine.
>
> However when I try to click to any referenced table:
>
>
> It shows this error:
>
> <type 'exceptions.AttributeError'> 'Row' object has no attribute 
> 'first_name'
> I already tried to separate queries in constraints like this:
>
>     query1 = db.auth_membership.user_id == db.auth_user.id
>     query2 = db.auth_membership.group_id == 1
>     grid = SQLFORM.smartgrid(db.auth_user,
>                              constraints=dict(auth_user=query1,
>                                               auth_membership=query2
>                                               ),
>                              deletable=False,
>                              editable=True,
>                              create=False,
>                              csv=False)
>
> However it still return same error when clicking in one of the referenced 
> tables.
>
>
>
> Do anyone have an idea of what am I doing wrong?
>
>

-- 

--- 
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.


Reply via email to