A list:reference field already gets a default "represent" attribute, as long as the referenced table has a "format" argument. However, the "represent" function (for any type of field) is only applied automatically in particular contexts (e.g., SQLTABLE, the grid, and read-only forms). In your case, you have to call it explicitly:
{{=db.course.book.represent(header.course.book)}} Anthony On Thursday, October 31, 2013 8:33:49 PM UTC-4, 黄祥 wrote: > > > hi, > > is there a way to have represent of list:reference field? > e.g. > models > db.define_table('book', > Field('title'), > Field('cover', 'upload'), > format = '%(title)s') > > db.define_table('course', > Field('course_name'), > Field('description', 'text'), > Field('book', 'list:reference book'), > Field('lecturer', 'list:reference lecturer'), > Field('price', 'decimal(10,2)'), > format = '%(course_name)s') > > db.define_table('registration', > Field('registration_no'), > Field('registration_date', 'date'), > Field('student', 'reference student'), > Field('course', 'reference course'), > Field('price', 'decimal(10,2)'), > Field('registration_fee', 'decimal(10,2)'), > Field('total_price', 'decimal(10,2)'), > format = '%(student)s %(course)s') > > controllers > def print_registration(): > header = db(db.registration.id == request.args(0)).select().first() > return dict(header = header) > > views > {{=header.course.book}} > > it return > [1L, 2L] > > how can show the other table field name (book title in registration) for > example : > learning japanese language for beginner, japanese language daily > conversation? > > thanks and best regards, > stifan > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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.