I get that part, however the primary key is what we call an un-natural key, 
which increases complexity for highly relational 
systems...increases probability of errors, etc. if used as a surrogate key.

I just saw a "not yet" error when I tried the other field, so I think it's 
not yet possible to reference directly to the other fields.

I guess I will live with it for now but recommend web2py admins consider 
building capability for references to non-primary keys

thanks,

Alex


On Sunday, February 24, 2013 3:32:40 PM UTC-8, 黄祥 wrote:
>
> plese see book
> http://web2py.com/books/default/chapter/29/06
>
>    - Keyed tables can only reference other keyed tables.
>    - Referencing fields must use the reference tablename.fieldname format.
>
>
> maybe you mean is format, so the basic is in define table you use 
> reference to other primary key other table which is id, and then in web 
> form you want to see the other field not the id.
>
> for example :
> # create table : company
> db.define_table('company',
>     Field('company_name', length=10, notnull=True, unique=True),
>     format='%(company_name)s')
>
> # create table : branch
> db.define_table('branch',
>     Field('address', 'text', notnull=True, unique=True),
>     Field('company', 'reference company', notnull=True),
>     format='%(address)s')
>
> when you add the web form branch, you will see the company_name value in 
> the field company, not the company id.
>

-- 

--- 
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.


Reply via email to