I know I'm late to the party, but I have to write to thank Anthony for
sharing such a wonderful trick!
One more thing, I happen to also discover that we do not have to use
lambda. The following form is less verbose, more intuitive.
db.define_table('room',
Field('room_no'),
Field('category', 'list:string'),
Field('status', 'list:string'),
Field('branch', 'reference branch'),
format='%(branch.address) %(room_no)s')
Thanks everyone, especially Massimo for building such an amazingly flexible
web2py!
Regards,
Ray
On Saturday, March 23, 2013 at 6:48:59 AM UTC-7, Anthony wrote:
>
> Oh, yeah, even better, you can make the "format" attribute a function (it
> takes a record of its own table) -- so:
>
> db.define_table('room',
> Field('room_no'),
> Field('category', 'list:string'),
> Field('status', 'list:string'),
> Field('branch', 'reference branch'),
> format=lambda r: '%s %s' % (r.branch.address, r.room_no))
>
> Anthony
>
> On Saturday, March 23, 2013 1:41:38 AM UTC-4, 黄祥 wrote:
>>
>> just curious, is it possible to add the format function in the table room?
>>
>>
>>
>>
>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.