I found a solution/workaround. For the records, I changed the format for the table cgc_schedule. Old one: format='%(training.short_title)s (%(training_date)s)'
New one: format=lambda row: row.training.short_title + ' (' + row.training_date. strftime('%d-%m-%Y') + ')' With that new format, it works. I'm still wondering why I need to use a lambda to have it working. If someone has a clue I'm all ears ;-) On Thursday, February 7, 2013 4:31:56 PM UTC+1, Calycé wrote: > > Hi all, > > I have an error in the database administration when using the following > code in db.py: > > db.define_table('cgc_service_categories', > Field('category', 'string', required=True), > Field('description', 'text', required=True), > Field('image', 'upload', required=True), > Field('display_order', 'integer'), > Field('link', 'string'), > format='%(category)s') > > db.define_table('cgc_trainings', > Field('category', db.cgc_service_categories), > Field('disporder', 'integer'), > Field('title', 'string', required=True), > Field('short_title', 'string', required=True), > Field('duration', 'string', required=True), > Field('planning', 'text', required=True), > Field('typical', 'text'), > Field('price', 'integer'), > Field('training_checks', 'boolean'), > Field('image', 'upload'), > format='%(short_title)s') > > db.define_table('cgc_schedule', > Field('training', db.cgc_trainings), > Field('location', 'string'), > Field('training_date', 'date'), > Field('vacancies', 'integer'), > format='%(training.short_title)s (%(training_date)s)') > > db.define_table('cgc_booking', > Field('training_date', db.cgc_schedule), > Field('company', 'string'), > Field('first_name', 'string'), > Field('last_name', 'string'), > Field('phone', 'string'), > Field('email', 'string'), > Field('seats', 'integer')) > > It works when I browse the existing records, but if I try to edit a record > or insert a new one with the database administration in the cgc_booking > table, I receive the following error: > <type 'exceptions.AttributeError'> 'Table' object has no attribute > 'training.short_title' > If I change the "format" for the cgc_schedule table to "%(training)s > (%(training_date)s)" it works but having only the id is useless in this > case. > > Is it a bug in the database administration or am I doing something wrong ? > > BTW, I'm using 2.3.2. > > Thanks for your help. > > > Calycé > > -- --- 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.