Hi guys,

Is there a way to filter an aggregation? Suppose the following code:

Book.objects.annotate(num_authors=Count('authors')).order_by
('num_authors')

How can I count only masculine authors or authors by age? I think a
cool way could be:

Book.objects.annotate(
   num_authors=Count('authors').filter(is_masculine=True
).order_by('num_authors')

This should be evaluated to a subselect. Anyway, this doesn't work. I
think the only way is to use an extra clause on the select, am I
right?

Thanks in advance,

--
Michel Sabchuk
http://turbosys.com.br/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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