this solved it from datetime import datetime from gluon.tools import Auth db = DAL(lazy_tables=True)
from gluon.tools import Auth, Service, PluginManager, prettydate auth = Auth(db, host_names = myconf.get('host.names') ) auth.define_tables(username = False, signature = True) db.define_table('employee', Field('fullname','string',label='Name'), Field('email','string'), Field('phone','string'), Field('kids', 'string'), Field('phone', 'string'), #Field('date','datetime'), Field('dob', 'datetime', label='Date'), Field('department', 'reference department',requires=IS_IN_DB(db, "department.id", '%(department_name)s')), auth.signature, format='%(fullname)s' ) #db = DAL(lazy_tables=True) db.define_table('department', Field('department_name', 'string', label='Department Name'), # Field('department_name', 'string', label='Department Name'), Field('manager', 'reference employee', requires=IS_IN_DB(db, "employee.id", '%(fullname)s')), format='%(department_name)s' ) Thanks to everyone On Sunday, August 14, 2016 at 11:02:56 PM UTC+2, Oasis Agano wrote: > > My code is the following im trying to assign a department to employees and > also create a manager in a department table > > db = DAL(lazy_tables=True) > db.define_table('employee', > Field('fullname','string',label='Name'), > Field('email','string'), > Field('phone','string'), > Field('kids', 'string'), > Field('phone', 'string'), > #Field('date','datetime'), > Field('dob', 'datetime', label='Date'), > Field('department', 'reference department', > requires=IS_IN_DB(db, db.department.id, > '%(department_name)s')), > auth.signature, > format='%(fullname)s' > > ) > db = DAL(lazy_tables=True) > db.define_table('department', > Field('department_name', 'string', label='Department Name'), > # Field('department_name', 'string', label='Department Name'), > Field('manager', 'reference employee', required='true', > requires=IS_IN_DB(db, db.employee.id, '%(fullname)s')), > auth.signature, > format='%(department_name)s' > ) > > -- 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.