auth.has_membership is not used to construct DAL queries -- it is for 
checking whether a given user actually has a given membership (it returns 
True or False). Also, its second argument should not be a DAL Field object.

You need to construct a query based on the db.auth_membership table.

Anthony

On Wednesday, December 21, 2016 at 11:13:17 PM UTC-5, 
antonella.ma...@yottacle.com wrote:
>
> Hi,
> in my model I have users who have membership to more groups.
> I am trying to perform a query of users who DO NOT belong to a group; 
> something along these lines:
>
> query = db ((db.auth_user != auth.user.id) & (~(auth.has_membership 
> ("admin", db.auth_user.id))).select (db.auth_user.first_name, 
> db.auth_user.last_name)
>
> The above query does not work, i.e. it retrieves all records except the 
> currently logged in user (which is OK) but ignores the "has_membership" 
> condition. It gives no errors, though...
>
> I know I can perform the select with only the first condition and then 
> loop over the result to remove the users that have membership to group 
> "admin", but I wonder if I can have the result in a single query.
>
> 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/d/optout.

Reply via email to