format strings and multiple levels of indirection

15 views
Skip to first unread message

rocket

unread,
Feb 14, 2011, 1:58:27 PM2/14/11
to web2py-users
Hi,

I have two tables defined like this:

db.define_table('t_client',
Field('f_name', type='string', notnull=True, label=T('Name')),
format='%(f_name)s')

db.define_table('t_project',
Field('f_name', type='string', notnull=True, label=T('Name')),
Field('f_tbte_project_number', type='string', notnull=True,
label=T('TBTE Project Number')),
Field('f_report_to', type='string', notnull=True, label=T('Report
To')),
Field('f_client', db.t_client, notnull=True, label=T('Client')),
format='%(f_tbte_project_number)s %(f_client)s - %(f_name)s')

My issue is when I reference t_project from another table, the format
string includes the record id of the client and not the client's name
string.

What is the way to display the client's name string instead of id from
a third table using best practices?

rocket

unread,
Feb 14, 2011, 6:43:15 PM2/14/11
to web2py-users
I think I've found the solution here:
http://groups.google.com/group/web2py/browse_thread/thread/1d94e9bfc9877769

format=lambda r: r.f_tbte_project_number + r.f_client.f_name
+r.f_name
Reply all
Reply to author
Forward
0 new messages