Regarding advance use of IS_IN_DB while referencing a model using other models

30 views
Skip to first unread message

Akash Agrawall

unread,
Apr 4, 2014, 5:50:25 PM4/4/14
to web...@googlegroups.com
I am well aware of the usage of IS_IN_DB in web2py however I want to select some particular values of the table in drop down.
Like presently this attribute selects all users registered in the application.

db.Field('selected_users','string',requires=IS_IN_DB(db,db.auth_user.id,'%(Name)s',zero=None))

However I just want to list down the verified users i.e.
the query should be:

query=((db.auth_user.id>0) & (db.auth_user.registration_key==""))

How do I fit it with the model:
Is this correct? Doesn't seem to work in my case though.
db.Field('selected_users','string',requires=IS_IN_DB(query,db.auth_user.id,'%(Name)s',zero=None))

Thanks in advance,
Regards,
Akash

黄祥

unread,
Apr 4, 2014, 6:04:12 PM4/4/14
to web...@googlegroups.com
please try (not tested)
requires = IS_IN_DB(db((db.auth_user.id > 0) & (db.auth_user.registration_key == "") ), db.auth_user.id, '%(first_name)s %(last_name)s')

best regards,
stifan

Akash Agrawall

unread,
Apr 4, 2014, 6:49:19 PM4/4/14
to web...@googlegroups.com
@steve Thanks. It worked for me. :)

Regards,
Akash


--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/2nrCGCnl634/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
akash.wanteds
Reply all
Reply to author
Forward
0 new messages