On Wed, Jan 20, 2010 at 3:42 AM, Collin Anderson
<collinmander...@gmail.com> wrote:
> Taking the example from:
> http://docs.djangoproject.com/en/dev/topics/db/aggregation/#filter-and-exclude
>
> Publisher.objects.filter(book__rating__gt=3.0).annotate(num_books=Count
> ('book'))
>
> Is there anyway to have the filter only apply to the annotation, so it
> would return all publishers, with some having a num_books=0?

If I understand your request correctly, I think this falls into the
category of annoyingly simple query that is hard to express in SQL -
you need to do a join on a subselect table to get the result. Django's
ORM doesn't handle joins on subselects. A raw query is probably your
best option.

Yours,
Russ Magee %-)
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to