Re: db filter comparing a minimum to a range

2010-09-13 Thread Phlip
Curiously, if I add another constraint to the dates, it must go into the Min() itself: Blog.objects.annotate(min_date= Min('comment__date', comment__status='sane')).all() Otherwise the date range check is disjoint from the sanity check (important for modern commenters!), and lots of rec

Re: db filter comparing a minimum to a range

2010-09-13 Thread Phlip
> Maybe this is what you want: > > http://docs.djangoproject.com/en/1.2/topics/db/aggregation/#filtering... Outrageous, thanks. I seem to have reconstructed the rational for .annotate(), which I didn't understand until now! -- You received this message because you are subscribed to the Google Gr

Re: db filter comparing a minimum to a range

2010-09-13 Thread Alec Shaner
Maybe this is what you want: http://docs.djangoproject.com/en/1.2/topics/db/aggregation/#filtering-on-annotations On Mon, Sep 13, 2010 at 3:32 PM, Phlip wrote: > Djangoids: > > Consider this QuerySet: > > Blog.objects.filter(comment__date__range=(self.yesterday, > self.tomorrow)) > > It retur

db filter comparing a minimum to a range

2010-09-13 Thread Phlip
Djangoids: Consider this QuerySet: Blog.objects.filter(comment__date__range=(self.yesterday, self.tomorrow)) It returns all the blogs with any comment (as a side note, it seems to return each blog redundantly, to allow the SELECT to differ each returned row by comment). I need every Blog who