ok on the foreign key, but web2py doesn't allow "non-id" to be references unless all the tables involved are keyed tables.
The *requires *I posted solves the problem if all the inserted data is being validated (so, either by form or by, e.g., db.table.validate_and_insert()), in the sense that the FK is checked by web2py upon insertion. If you want a FK on the database you have to create it in the database itself, without using web2py. Il giorno lunedì 20 maggio 2013 13:49:49 UTC+2, Chris Teodorski ha scritto: > > What I'm trying to do -- and obviously not explaining well is to have > t_teams.name to be a foreign key for the field custom field in auth_users. > > Does that explain it any better? > > On Monday, 20 May 2013 02:59:00 UTC-4, Niphlod wrote: >> >> uhm. >> what do you want (as examples) in auth_user.team_name and what on >> t_teams.name ? >> if you want e.g. "a-team" in auth_user.team_name and "a-team" in >> t_teams.name, and a record in t_teams must exist only with a "name" that >> is one of the team_name values of the auth_user table (i.e. you have to >> create the user BEFORE the t_teams), then you can't create that reference. >> >> You should use a Field('name', requires=IS_IN_DB(db, >> 'auth_user.team_name')) >> >> >> >> >> -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.