Vincenzo: Have you looked at: https://github.com/niphlod/w2p_tvseries

On Sat, Jul 28, 2012 at 7:18 PM, Vincenzo Ampolo
<[email protected]>wrote:

> Hi,
>
> Is there a way to get many to many relationship data easily?
> The web2py book says
> http://web2py.com/books/default/chapter/29/6#Many-to-many that "it may
> be convenient to define a new set on which to perform operations" and it
> basically does a join between the fields.
>
> But what if I've this models:
>
> db.define_table('genres',
>         Field('name')
>         )
>
> db.define_table('movies',
>         Field('imdb_id', 'integer'),
>         Field('title'),
>         Field('poster', 'text'),
>         Field('trailer', 'text'),
>         Field('plot', 'text'),
>         Field('date', 'datetime'),
>         Field('updated', 'datetime')
>         )
>
> db.define_table('movies_genres',
>         Field('movie', db.movies, requires=IS_IN_DB(db, 'movies.id',
> db.movies._format)),
>         Field('genre', db.genres, requires=IS_IN_DB(db, 'genres.id',
> db.genres._format))
>         )
>
> and i do:
>
> movie = db.movies[1]
>
> movie has an movies_genres which is a set. can I use movie.movies_genres
> to get a genre instance ?
> I'm asking this because I'm in a view and I would like a compact way to
> print genre.name from a movie instance.
>
> Thank you
>
> best regards,
> --
> Vincenzo Ampolo
> http://vincenzo-ampolo.net
> http://goshawknest.wordpress.com
>
> --
>
>
>
>

-- 



Reply via email to