I know two options for you: 1. First use django-simpleaggregation plugin, you canfind it on googlecode.com 2. Or use raw sql to do it. This is example how I count entries in each blogs
blogs = Blog.objects.all().extra(select={'article_count': "SELECT COUNT(*) FROM blog_article a WHERE a.blog_id=blog_blog.id"}) You can easy extend by example to a custom manager, that can aggregate anything [EMAIL PROTECTED] wrote: > I'm new to Django, so this may be answered elsewhere but I have not > found it. > > If I want to display a summary view of some large datasets, in SQL I > would use: > > select name, count(*) from MyTable group by name > > This SQL in practice would have several joins. In past lives, I've > used SQL VIEWS to hide the details of where this summary view of the > data is constructed. > > How can I display a table of groups and counts, using the DB API? Can > this be wrapped around a model that is tied to a database view? > > -Dave --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---