[web2py] Re: One to many question

2012-01-10 Thread Anthony
On Tuesday, January 10, 2012 8:56:34 AM UTC-5, Marcello wrote: Hello, Maybe this is a stupid question. But I could not find the answer anywhere I have, for example, 2 tables: db.define_table('account', Field('name','string'), migrate=False) db.define_table('user',

[web2py] Re: One to many question

2012-01-10 Thread Marcello
Yes... I forgot to say that... But this is a legacy database, and I can't rename the field Thanks Anthony On 10 jan, 12:16, Anthony abasta...@gmail.com wrote: On Tuesday, January 10, 2012 8:56:34 AM UTC-5, Marcello wrote: Hello, Maybe this is a stupid question. But I could not

[web2py] Re: One to many question

2012-01-10 Thread Ross Peoples
You might be able to do something like this to trick it into being a virtual field: db.user.account = Field.Virtual(lambda row: row.account_id) This just makes a virtual field account which returns the value of account_id. This will only work with reads, though. If you try to set a value to

Re: [web2py] Re: One to many question

2012-01-10 Thread Bruno Rocha
may be db.user.account = db.user.account_id should work in controllers -- Bruno Rocha [http://rochacbruno.com.br]

Re: [web2py] Re: One to many question

2012-01-10 Thread Ross Peoples
Bruno, I've never tried that way before. Will that cause web2py to create a new field account?

Re: [web2py] Re: One to many question

2012-01-10 Thread Bruno Rocha
On Tue, Jan 10, 2012 at 1:16 PM, Ross Peoples ross.peop...@gmail.comwrote: Bruno, I've never tried that way before. Will that cause web2py to create a new field account? You are right, I am wrong (forget what I said) This works only for Rows rows = db(db.table).select() for row in rows: