l=db(db.Books.Author.contains(Author.id)).select(db.Books.ALL, orderby=db:Books.Name)--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/bnP-qe7Nwwk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
def Authors():
AL=db().select(db.Author.ALL, orderby=db.Author.Name)
TheList=[]
for Author in AL:
l=db(db.Book.Author.contains(Author.id)).select(db.Book.ALL, orderby=db.Book.Name)
if len(l)>0:
TheList.append([l[0]])
else:
TheList.append([])
return dict(AL=AL,BookList=TheList)<table>
{{i=0}}
{{for Author in AL:}}
<tr>
<td>{{=Author.Name}}</td><td></td>
</tr>
{{for b in BookList[i]:}}
<tr>
<td></td><td>{{=b.Name}}</td>
</tr>
{{pass}}
{{i+=1}}
{{pass}}
</table>db(db.Book.Author == Author.id).select(db.Book.ALL, orderby=db.Book.Name)thats why.thanks richard for your solution it works perfectly.
--