Re: Yet another __ne not equal discussion

2012-12-05 Thread Marek Brzóska
2012/11/30 Shai Berger > On Friday 30 November 2012, Marek Brzóska wrote: > > Has the matter been completely put away? > > > > I would like to bring it up again. > > > > I have Articles and Categories. An Article belongs to Categories: > > > > class Category(model): > > pass > > class Article(m

Re: Yet another __ne not equal discussion

2012-11-30 Thread Anssi Kääriäinen
On 30 marras, 19:16, Florian Apolloner wrote: > On Friday, November 30, 2012 6:12:43 PM UTC+1, Shai Berger wrote: > > > live_articles = Article.objects.exclude(status="archived") > > live_cats = Category.objects.filter(article__in=live_articles) > > That works and it has the positive side-effect

Re: Yet another __ne not equal discussion

2012-11-30 Thread Anssi Kääriäinen
On 30 marras, 15:29, Marek Brzóska wrote: > Has the matter been completely put away? > > I would like to bring it up again. > > I have Articles and Categories. An Article belongs to Categories: > > class Category(model): >   pass > class Article(model): >   category = ManyToManyField(Category) >  

Re: Yet another __ne not equal discussion

2012-11-30 Thread Florian Apolloner
On Friday, November 30, 2012 6:12:43 PM UTC+1, Shai Berger wrote: > > live_articles = Article.objects.exclude(status="archived") > live_cats = Category.objects.filter(article__in=live_articles) > That works and it has the positive side-effect to kill any mysql server in a matter of seconds :)

Re: Yet another __ne not equal discussion

2012-11-30 Thread Shai Berger
On Friday 30 November 2012, Marek Brzóska wrote: > Has the matter been completely put away? > > I would like to bring it up again. > > I have Articles and Categories. An Article belongs to Categories: > > class Category(model): > pass > class Article(model): > category = ManyToManyField(Cate

Re: Yet another __ne not equal discussion

2012-11-30 Thread Alex Ogier
To be fair, the query you describe is significantly more expensive than Marek's query. On Fri, Nov 30, 2012 at 10:20 AM, Tom Evans wrote: > On Fri, Nov 30, 2012 at 2:51 PM, Marek Brzóska > wrote: > > > > > > > > 2012/11/30 Tom Evans > >> > >> On Fri, Nov 30, 2012 at 1:29 PM, Marek Brzóska > >

Re: Yet another __ne not equal discussion

2012-11-30 Thread Marek Brzóska
> > >> What precisely is wrong with: > >> > >> Category.objects.exclude(article_status='archived') > > > > It excludes all categories that have at least one archived article. > > > > And I want categories that have at least one NOT archived article. > > > > Example: I have one category: politics. I

Re: Yet another __ne not equal discussion

2012-11-30 Thread Tom Evans
On Fri, Nov 30, 2012 at 2:51 PM, Marek Brzóska wrote: > > > > 2012/11/30 Tom Evans >> >> On Fri, Nov 30, 2012 at 1:29 PM, Marek Brzóska >> wrote: >> > Has the matter been completely put away? >> > >> > I would like to bring it up again. >> > >> > I have Articles and Categories. An Article belong

Re: Yet another __ne not equal discussion

2012-11-30 Thread Marek Brzóska
2012/11/30 Tom Evans > On Fri, Nov 30, 2012 at 1:29 PM, Marek Brzóska > wrote: > > Has the matter been completely put away? > > > > I would like to bring it up again. > > > > I have Articles and Categories. An Article belongs to Categories: > > > > class Category(model): > > pass > > class Art

Re: Yet another __ne not equal discussion

2012-11-30 Thread Tom Evans
On Fri, Nov 30, 2012 at 1:29 PM, Marek Brzóska wrote: > Has the matter been completely put away? > > I would like to bring it up again. > > I have Articles and Categories. An Article belongs to Categories: > > class Category(model): > pass > class Article(model): > category = ManyToManyField(C

Re: Yet another __ne not equal discussion

2012-11-30 Thread Marek Brzóska
Has the matter been completely put away? I would like to bring it up again. I have Articles and Categories. An Article belongs to Categories: class Category(model): pass class Article(model): category = ManyToManyField(Category) status = CharField(max_length=10) Now I want all categories

RE: Yet another __ne not equal discussion

2011-10-27 Thread Kääriäinen Anssi
""" The exclude() option in its current form is unworkable on multi-valued relations. I'd like to repeat that for emphasis: exclude() can *never* obsolete direct negative lookups for multi-value relations. """ I do see a problem here: the equality ~Q(a=1) <-> Q(a__lt=1)|Q(a__gt=1) is not correct i

Re: Yet another __ne not equal discussion

2011-10-27 Thread Adam Moore
Opps! ... >     ).extra(where=['`data_school`.`site_name` != RAE'] should be ).extra(where=['`data_school`.`site_name` != %s'], params=['RAE'] which is case-in-point for why helping me avoid extra() is a good thing! ~Adam sM -- You received this message because you are subscribed to the Go

Re: Yet another __ne not equal discussion

2011-10-27 Thread Adam Moore
On Oct 27, 6:26 am, Kääriäinen Anssi wrote: > > Adam Moore wrote: > > It's also worth noting that Q() objects permit the unary negation > > operator, but this also yields the undesired results of the exclude() > > call: > > Blog.objects.filter(~Q(entry__author_count=2), > > entry__tag__name='dja

RE: Yet another __ne not equal discussion

2011-10-27 Thread Kääriäinen Anssi
Quote: """ It's also worth noting that Q() objects permit the unary negation operator, but this also yields the undesired results of the exclude() call: Blog.objects.filter(~Q(entry__author_count=2), entry__tag__name='django') """ As far as I understand, this is exactly the query you want. The fil

Yet another __ne not equal discussion

2011-10-27 Thread Adam Moore
Greetings! Thanks to everyone for Django! Long story short, I believe certain queries that are straightforward and easy in plain SQL are not directly achievable in Django at all. Obviously, Django is flexible enough that there is a workaround - but a workaround shouldn't be necessary in a framewor