Thanks DenesL! That was definitely the issue.
On Apr 12, 12:21 pm, DenesL <[email protected]> wrote: > Move the requires from inside the field definition to after the table > definition. > web2py will not allow a reference to a field that has not been > created. > > On Apr 12, 12:01 pm, Mike <[email protected]> wrote: > > > > > > > > > I know this question has been asked and answered before, but I am > > having errors in implementation and I feel like it's something really > > silly. If anyone can point anything obvious out that I am missing, > > please let me know. Basically I am trying to implement so that two > > rows can not have the same combination of Invoice + SKU. Now when I > > just got to the web2py admin database editor I am getting these > > errors. > > > Thanks in Advance! > > > Error message: > > > Traceback (most recent call last): > > File "/home/msheiny/Dropbox/web2py/gluon/restricted.py", line 188, > > in restricted > > exec ccode in environment > > File "/home/msheiny/Dropbox/web2py/applications/mycybersoft/models/ > > mycyber_model.py", line 5, in <module> > > Field('Invoice', > > type='integer',requires=(IS_NOT_EMPTY(),IS_INT_IN_RANGE(1, > > 9999999,error_message=T('Needs to be between 1 - > > 9999999')),IS_NOT_IN_DB(db(db.software_database.SKU==request.vars.SKU),'sof > > tware_database.Invoice')), > > File "/home/msheiny/Dropbox/web2py/gluon/dal.py", line 3904, in > > __getattr__ > > return self[key] > > File "/home/msheiny/Dropbox/web2py/gluon/dal.py", line 3898, in > > __getitem__ > > return dict.__getitem__(self, str(key)) > > KeyError: 'software_database' > > > Database in question with validator on Invoice field: > > > db.define_table('software_database', > > Field('Invoice', > > type='integer',requires=(IS_NOT_EMPTY(),IS_INT_IN_RANGE(1, > > 9999999,error_message=T('Needs to be between 1 - > > 9999999')),IS_NOT_IN_DB(db(db.software_database.SKU==request.vars.SKU),'sof > > tware_database.Invoice')), > > label=T('Invoice Number')), > > Field('Company_Name', > > type='string',requires=(IS_NOT_EMPTY(),IS_IN_DB(db,'auth_user.Company','',z > > ero=T('choose > > one'))), > > label=T('Company Name')), > > > Field('Start_Date','date',default=now,writable=False,requires=(IS_NOT_EMPTY > > (),IS_DATE()),label=T('Start > > Date')), > > > Field('Expire_Date','date',default=thirtydaysout,requires=(IS_NOT_EMPTY(),I > > S_DATE()),label=T('Expiration > > Date')), > > Field('SKU', requires=IS_IN_DB(db,'cyber_skus.SKU','% > > (SKU)s',zero=T('CyberSoft Product')),label=T('SKU')), > > Field('NumOfCopies', > > type='integer',requires=IS_NOT_EMPTY(),label=T('Number of Copies')), > > Field('Comments', type='string',label=T('Optional Comments')), > > Field('Assoc_Usernames', 'list:reference auth_user'), > > format='%(username)s', > > migrate=settings.migrate)

