I am trying to query a database table from the view in web2py as I need to take a field from another table for each row in the present table so I have written a code like this:
{{for recipe in rows:}}
<div class="well">
<table>
<tr>
<td>
<div style="text-align:center">
<img width="200px"
src="{{=URL('download', args=db(db.uploads.recipe_id==recipe.id).select().first().up_file)}}" />
</div>
</td>
<td><button>
-
</button></td><td><span class='votes'>{{=recipe.votes}}</span></td><td><button>
+
</button><td><strong>{{=A("comments",_href=URL('view_posts',args=recipe.id))}},{{=recipe.name}}</strong></td></td></tr>
</table>
</div>
{{pass}}
but I have a doubt whether we could query a database from a view or not? If not how could I query the same from the controller and return it to the view? This may be a silly doubt,but sorry I am new to web2py