On 8/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > 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?
The short answer is that aggregates are a planned, but not yet implemented feature. The ticket discussing the issue is #3566. The longer answer is that there are some ways to get aggregates into Django, but they aren't as 'pretty' as the rest of Django. One approach is to make raw SQL calls. Another approach is to bend the existing query commands (like extra()) in unintended ways. This will hopefully get better in the very near future, as one of the Django core developers is working on a rewrite of the internal query composing interface. Yet another way to approach the problem is using views. Django models can be made to wrap around existing database tables - they are also largely compatible as wrappers around database views that have been constructed externally to Django. Django doesn't currently have a representation for views, so you will need to contruct the view yourself, and Django won't provide any protection to ensure you are using the view correctly, but you can use a view to access aggregate data using the Django ORM. This technique (and how to do it) has been discussed previously on the Django-users lists. 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-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 -~----------~----~----~----~------~----~------~--~---