I created a brand new app for this.
Code:
db.define_table('location',
Field('city', 'string',length=255,requires=IS_NOT_EMPTY()),
Field('state', 'string',length=255,requires=IS_NOT_EMPTY()),
Field('country', 'string',length=255,requires=IS_NOT_EMPTY()),
)
db.define_table('person',
Field('name','string',length=255,requires=IS_NOT_EMPTY()),
Field('location_id','reference location',default=location.id),
)
And the error that comes up is:
<type 'exceptions.NameError'> name 'location' is not defined
Traceback (most recent call last):
File "/Users/xxx/web2py/source/gluon/restricted.py", line 205, in restricted
exec ccode in environment
File "/Users/xxx/web2py/applications/newapp/models/main.py"
<http://127.0.0.1:8000/admin/edit/babybook/models/main.py>, line 40, in <module>
Field('location_id','reference location',default=location.id),
NameError: name 'location' is not defined
Funny thing is, the exact same code ("reference <some_table>") is working on
other apps, but why not this new app?
Thanks.
--