Did you not read the responses to this question
here<https://groups.google.com/d/topic/web2py/uqBF0fzVWuA/discussion>or on
Stack
Overflow <http://stackoverflow.com/a/13646871/440323>?
Anthony
On Friday, November 30, 2012 2:17:57 PM UTC-5, Samuel Komfi wrote:
>
> I have a db_agents model:
> *
> *
> db.define_table('agents',
> Field('user_id', db.auth_user),
> Field('event_instance_id', db.event_instance), # this is the line
> giving the error
> Field('code')
> )
>
>
> db.agents.user_id.requires = IS_IN_DB(db, db.auth_user.id, '%(username)s')
> db.agents.event_instance_id.requires = IS_IN_DB(db, db.event_instance.id,db
> .event_instance._format)
> db.agents.code.requires = IS_NOT_EMPTY()
>
>
> And a db_event model:
>
> db.define_table('event',
> Field('name', unique=True),
> Field('sponsor_id', db.sponsors),format='%(name)s'
> )
>
>
> db.define_table('event_instance',
> Field('event_id', db.event),
> Field('venue_id', db.venue),
> Field('direct_comms_only', 'boolean'),
> Field('event_instance_name'),
> Field('display_name'),
> Field('startdate', 'datetime'),
> Field('enddate', 'datetime'),
> Field('regstart_date', 'datetime'),
> Field('regclose_date', 'datetime'),
> Field('website_title'),
> Field('mm_open_date', 'datetime'),
> Field('mm_close_date', 'datetime'),format='%(event_instance_name)s'
> )
>
>
>
> The problem is I keep getting this error: *'DAL' object has no attribute
> 'event_instance' *
>
> I would like to know if its possible to have a table with PK
> event_instance in db_event.py and then have FK event_instance_id in table
> db_agents.py.
> The only other way is to define the tables in the same file, but tried
> that, it worked, but the same error appeared pointing to the db.sponsor
> attribute as non-existant. To fix it I will have to declare the sponsor
> table in the same model file before the event table. That is where I have
> issues, I don't want to declare all my tables in one model file, there are
> so many of them related to each other. Is there another way?
> *
> *
>
--