On 07/28/2012 03:38 AM, Alec Taylor wrote: > Vincenzo: Have you looked at: https://github.com/niphlod/w2p_tvseries
What is that ? I can't figure out from the "objectives" section what that application does... On 07/28/2012 05:37 AM, Cliff Kachinske wrote:> You need to define a set that includes all three tables in the relation. > > ((db.genres.id==db.movies_genres.genres_id) & > (db.movies_genres.movie_id==db.movies.id)) > > To get the set of genres for a specific movie, do > > | > ((db.genres.id==db.movies_genres.genres_id)& > (db.movies_genres.movie_id==db.movies.id)& > (db.movies.id==1))# or whatever variable you like > | > > > Notice this query allows you to retrieve information from all three > tables at one time. Which is exactly like the web2py books suggests. Btw to retrieve all the information of a movie in one shot (so join movie with genres with casts with pictures) may be really database intense (3 joins!) So after a bit of hacking I figured out a simply way to accomplish the same goal: web2py automatically add the many-to-many sets to an instance with the same name of the relation table. In my case I've movie.movies_genres for each movie. Given so I can easily get the genres of a movie in a template just doing. In [36]: for m in movie.movies_genres.select(): print m.genre.name Thriller Best Regards, -- Vincenzo Ampolo http://vincenzo-ampolo.net http://goshawknest.wordpress.com --

