Foreign keys in web2py database

I am using web2py framework with two tables. How can I assign one field from the first table to the second table?

+5
source share
2 answers

Here's a section on table and JOINs relationships from the web2py chapter on databases

To illustrate how to implement one to many relationships with web2py DAL, define another table called β€œdog” that refers to the table β€œperson”, which we will redefine here:

>>> db.define_table('person',
                    Field('name'),
                    format='%(name)s')
>>> db.define_table('dog',
                    Field('name'),
                    Field('owner', db.person),
                    format='%(name)s')

You will need to provide additional information if you are looking for something that is not described in this link.

+7
source

. , , . / , . . , example.

+1

All Articles