I'm having problems getting tables linked in web2py using reference
fields.  For example, I have a model with table student and table
contact.  Table auth_user contains my app's users.  In db.py, under
db.define_table('auth_user') I have the following code to reference a
one-to-many relationship between users:students and users:contacts:

 Field('student', db.student),
 Field('contact', db.contact),

But I keep getting the following error:

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 192, in
restricted
    exec ccode in environment
  File "/home/www-data/web2py/applications/teachertext/models/db.py",
line 61, in <module>
    Field('student', db.student,
  File "/home/www-data/web2py/gluon/dal.py", line 4331, in __getattr__
    return self[key]
  File "/home/www-data/web2py/gluon/dal.py", line 4325, in __getitem__
    return dict.__getitem__(self, str(key))
KeyError: 'student'

I'm new to web2py (but not to frameworks) and this is my first time
referencing foreign keys in a web2py app.  I'm sure I'm missing
something obvious but I'd be grateful if someone could point it out
for me.

Thank you,

Eric

Reply via email to