when you fetch fields from different tables, as you highlighted already, 
you don't have a resultset holding just columns, you have a dict holding 
table that hold fields.

i.e. single table, named "test_table" with 2 fields, "field_1" and 
"field_2" will return a structure like

{'field_1': value1, 'field_2': value2 }

opposed to two tables, named "test_table1" and "test_table2" each one 
holding "field_1" and "field_2" will return a structure like

{'test_table1' : {'field_1': value1, 'field_2': value2 } , 'test_table2' : 
{'field_1': value1, 'field_2': value2 } }

so........if you want to get to the "value1" stored into the first field of 
the first table, you'd need in the first case to do just

row.field_1

while in the second case you'd need also the table name

row.test_table1.field_1



On Wednesday, August 12, 2015 at 7:49:13 AM UTC+2, Iancic Bogdan wrote:
>
> I have the following query: available_designs = db(db.component.id
> ==db.component_stock.fk_stock_component)(db.stock.fk_componentstock_authuser==auth.user).select()
> which returns me a row: <Row {'component': {'component_description': 'x ', 
> 'id': 1L, 'component_code': 'A253', 'path_to_source_file': 'x', 'name': 
> 'y'}, 'stock': {'fk_stock_user': 1L, 'fk_stock_component': 1L, 
> 'prints_available': 20L, 'id': 4L}}>
>
> in view I want to print a table having the following columns: name, 
> component_description, prints_available from the row that the query returns
>
> I don't know how to parse the row that the query returns. Could anyone 
> help?
>
> This is what i have written in view:
> {{if available_designs:}}
> <h3>{{=T('Designs available for print:')}}</h3>
> {{i=0}}
> <table>
>     <thead>
>             <th>#</th>
>             <th>{{=T('Component name')}}</th>
>             <th>{{=T('Description')}}</th>
>             <th>{{=T('Prints available)}}</th>
>     </thead>
>     <tbody>
>         {{for design in available_designs:}}
>             <tr><td>{{=i+1}}</td><td>{{=design.name
> }}</td><td>{{=design.component_description}}</td><td>{{=design.prints_available}}</td></tr>
>         {{pass}}
>     </tbody>
> </table>
> {{i=i+1}}
> {{pass}}
>

-- 
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/d/optout.

Reply via email to