Below, you still have that extra db = DAL(...) line, which needs to be removed.
On Tuesday, August 16, 2016 at 5:10:04 AM UTC-4, 黄祥 wrote: > > i think the error related with auth definition is not found, perhaps > because you define the employee table first and then (or not) auth > definition. > pls try : > > 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, 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' > ) > > as you can see on the example above, you define the db first, then the > auth, after that pls proceed with another table you want to have in your > apps. > > best regards, > stifan > > On Tuesday, August 16, 2016 at 3:35:14 PM UTC+7, Oasis Agano wrote: >> >> *I did this * >> >> 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, "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')), >> auth.signature, >> format='%(department_name)s' >> ) >> >> now im getting a complete different error >> >> raise KeyError('Cannot resolve reference %s in %s definition' % >> (referenced, table._tablename)) >> KeyError: 'Cannot resolve reference auth_user in employee definition' >> >> >> 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.