I am trying to show the detail for a foreign key, but I really do not know how to do it.
My model is: db.define_table('currency', SQLField('code',length=3), SQLField('name',length=100)) db.currency.code.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB (db,'currency.code')] db.currency.name.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB (db,'currency.name')] db.define_table('bank', SQLField('name', length=150) ) db.define_table('cash_account', SQLField('name', length=150), SQLField('bank', db.bank), SQLField('currency', db.currency) ) My controler is def list_banks_and_accounts(): banks=db().select(db.bank.ALL,orderby=db.bank.name) return dict(banks=banks) My view is: {{extend 'layout.html'}} <h1>This is the test/list_banks.html template</h1> <BR/> <a href="/{{=request.application}}/bank/new_bank"><button type="button">Create new bank</button></a> <a href="/{{=request.application}}/bank/ new_bank_account"><button type="button">New bank account</button></a> </b> <BR/> {{for bank in banks:}} <b><TR> <a href="/{{=request.application}}/bank/edit_bank/ {{=bank.id}}">{{=bank.name}}</a> </TR> <br/> {{cash_accounts = db(db.cash_account.bank==bank.id).select()}} {{for cash_account in cash_accounts:}} <TR> {{=cash_account.currency}} {{=cash_account.name}}</ TR> <a href="/{{=request.application}}/bank/edit_bank_account/ {{=cash_account.id}}"><button type="button">Edit</button></a><br/> {{pass}} <br/> {{pass}} What I would like to see is the currency code ("USD", "GBP", "JPY"....) instead of the foreign key id (an integer). How can I show the currency code, instead of the foreign key id {{=cash_account.currency}}? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---