I'm going to give this a try -- but I'm honestly not sure exactly what this
field definition does. I'm going to play with it a bit and RTFM to see if
I can figure it out.
On Monday, 20 May 2013 09:26:23 UTC-4, Anthony wrote:
>
> Would it work for you to just have a foreign key reference to the
> auth_user primary key, which is the id field? You could set the "represent"
> attribute of the "name" field to display the "team_name" value from the
> referenced auth_user record.
>
> db.define_table('t_teams',
> Field('name', db.auth_user,
> requires=IS_IN_DB(db, 'auth_user.id', '%s(team_name)s'),
> represent=lambda id, r: db.auth_user(id).team_name))
>
> Anthony
>
> On Monday, May 20, 2013 7:49:49 AM UTC-4, Chris Teodorski wrote:
>>
>> 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.