On Mon, 2008-11-10 at 14:52 -0800, chris wrote:
> Now, to answer myself, I found the solution:
> 
> qs =
> Reference.objects.all().extra(select={'title_count' 
> :'COUNT(*)'}).values('title',
> 'title_count')
> qs.query.group_by = ['title']
> 
> This gives me exactly the aggregated list of titles with the number of
> occurrences.  The trick with group_by is undocumented, but mentioned
> in this blog post by Eric Florenzano: 
> http://www.eflorenzano.com/blog/post/secrets-django-orm/

It's almost as if Django doesn't have public API support for aggregation
yet. Wait ... it doesn't! It's coming soon. The reason the Query class
API is internal (it will always be internal and hence not restricted by
the backwards compatibility guarantees, even when docs/internal/
contains something about it) is because there's been an ongoing project
to add a public API for aggregation stuff. It's getting closer; not
quite there yet, but on the path for 1.1

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to