I'd like to see this type of support in the main branch, not separated.
It seems that better support for floating point is just a deficiency in
Django today and the aggregation need crops up everywhere - not just in
scientific applications.

My needs for aggregation are simply for reporting: e.g. show the market
value and P&L of all 2000 positions in our fund grouped by strategy,
analyst, sector, etc. I've been experimenting with three different
ways:

- custom SQL: easy to write the queries but doesn't leverage Django
models at all. I can't reference fields on related objects since I'm
not going through the manager and I can't "reuse" common QuerySet
helpers to ensure I'm always doing the same basic select and filtering.

- aggregation in Python: I've written a group_by() function to take a
QuerySet and perform aggregation, returning a collection of objects
that have properties compatible with the model fields. This makes it
more natural to use the results of the grouping in a template, but it
still doesn't handle related objects and the aggregation in Python
isn't as efficient as the database can do it.

- wrapping the DB API sql clause: The idea here is to generate the SQL
experssion that does the aggregation as an outer select and use the
resulting QuerySet sql clause as the subselect that yields the rows for
the aggregation. The nice thing is that it would completely reuse the
QuerySet and still do aggregation on the DB. But it still returns just
a DB cursor which has no connection back to the Django model classes.

I'd love to see more attention on this topic. At first I was surprised
that aggregation isn't supported by the DB API since it seems so
elementary to any database API, but after playing around with a few
ideas, I can see its a harder problem than I originally thought.

-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
-~----------~----~----~----~------~----~------~--~---

Reply via email to