Re: possible to filter ManyToMany results?

2006-04-19 Thread nkeric
Luke Plant wrote: > As I understand it, Django should be able to do this query no problem. > I think there may be a mistake in what you posted though - IIRC, I > would have expected the method name to be 'get_articles_list' not > 'get_article_list', since you defined it as 'articles = >

Re: possible to filter ManyToMany results?

2006-04-14 Thread Ivan Sagalaev
Luke Plant wrote: >As I understand it, Django should be able to do this query no problem. > > I also thought so :-). I created a test project with this model and tried to get this query to work. "get_article_list" is indeed there but it doesn't like 'article_type__id__exact' as an

Re: possible to filter ManyToMany results?

2006-04-14 Thread Ivan Sagalaev
nkeric wrote: >Really? That's cool! > > Yes. One of the great new features of m-r branch is that relation queries work similary for M-M and 1-M relations and in both directions: game.articles.filter(article_type__pk=1) # all articles for one game of one type article.game_set.all() #

Re: possible to filter ManyToMany results?

2006-04-14 Thread Luke Plant
On Wednesday 12 April 2006 07:03, nkeric wrote: > hi all, > > I've done some search, however, I guess I should ask for your helps > here: > > I have the following models: (pseudo code) > > class ArticleType: > name = ... > > class Article: > title = ... > article_type =

Re: possible to filter ManyToMany results?

2006-04-14 Thread Ivan Sagalaev
nkeric wrote: >Ivan, thanks a lot for your reply :) >well, I guess I have to take the "dirty" sql approach :p > > You might want to look into magic-removal branch where things like this are made possible with ORM. --~--~-~--~~~---~--~~ You received this

Re: possible to filter ManyToMany results?

2006-04-13 Thread nkeric
Ivan Sagalaev wrote: > nkeric wrote: > > >hello, could anybody pls help? I don't want to write dirty sql if I > >could do it via django ORM... > > > > > Well... The only thing I could work out is this: > > articles = [a for a in g.get_article_list() if a.article_type_id == 1] Ivan, thanks a lot

Re: possible to filter ManyToMany results?

2006-04-12 Thread Ivan Sagalaev
nkeric wrote: >hello, could anybody pls help? I don't want to write dirty sql if I >could do it via django ORM... > > Well... The only thing I could work out is this: articles = [a for a in g.get_article_list() if a.article_type_id == 1] Drawbacks are obvious: it's always selects all

Re: possible to filter ManyToMany results?

2006-04-12 Thread nkeric
hello, could anybody pls help? I don't want to write dirty sql if I could do it via django ORM... BiG thanks! :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

Re: possible to filter ManyToMany results?

2006-04-12 Thread nkeric
Ivan Sagalaev wrote: > g.get_article_list(article_type_id__exact=1) > It's g.get_article_list(article_type__id__exact=1). Note 2 underscores > before "id" which means field "id" of a parent table. sorry for mistyped that, I tried this: >>> g.get_article_list(article_type__id__exact=1)

Re: possible to filter ManyToMany results?

2006-04-12 Thread Ivan Sagalaev
nkeric wrote: >class ArticleType: >name = ... > >class Article: >title = ... >article_type = meta.ForeignKey(ArticleType) > >class Game: >name = ... >articles = meta.ManyToManyField(Article) > >how can I retrive the articles of a certain article type of a given >game? > > >

possible to filter ManyToMany results?

2006-04-12 Thread nkeric
hi all, I've done some search, however, I guess I should ask for your helps here: I have the following models: (pseudo code) class ArticleType: name = ... class Article: title = ... article_type = meta.ForeignKey(ArticleType) class Game: name = ... articles =