Re: Confused with annotate() and filter().

2009-01-20 Thread Ty
@Alex: Nope, that's only pulling back entry's that have approved comments. On Jan 20, 12:43 pm, "alex.gay...@gmail.com" wrote: > On Jan 20, 11:53 am, tlow wrote: > > > > > I think you can not do that with only one query using annotate. > > > You could do it manually in python using the code ab

Re: Confused with annotate() and filter().

2009-01-20 Thread Ty
I'm currently using the extra method (subquery) and it's working perfectly. Thanks for clearing that up for me Thomas. On Jan 20, 11:53 am, tlow wrote: > I think you can not do that with only one query using annotate. > > You could do it manually in python using the code above including the > a

Re: Confused with annotate() and filter().

2009-01-20 Thread alex.gay...@gmail.com
On Jan 20, 11:53 am, tlow wrote: > I think you can not do that with only one query using annotate. > > You could do it manually in python using the code above including the > additional filter on comment_approved and merge all (entry, number) > pairs with Entry.objects.all() using 0 for entries w

Re: Confused with annotate() and filter().

2009-01-20 Thread tlow
I think you can not do that with only one query using annotate. You could do it manually in python using the code above including the additional filter on comment_approved and merge all (entry, number) pairs with Entry.objects.all() using 0 for entries which are not listed in your first query. Si

Confused with annotate() and filter().

2009-01-20 Thread Ty
Here are my models: class Entry(models.Model): name = models.CharField(max_length=200, unique=True) date_published = models.DateTimeField() is_published = models.BooleanField(default=False) class Comment(models.Model): entry = models.ForeignKey('Entry') na