I haven't looked into your specific use case in detail, but it *might*
be possible to do this with a custom aggregate. SUM, COUNT etc are all
just classes in Django, so you can extend and define your own if you
want.
Ticket #11305 [1] seems to describe almost exactly the feature you are
asking for (although they wanted COUNT, not SUM); in the discussion
for the ticket, Alex gives a code sample implementing conditional
aggregates.
There were also discussions on django-users back when aggregates were
introduced, describing how to define a custom aggregate [2].
Both these references are worth a look.
[1] https://code.djangoproject.com/ticket/11305
[2] http://groups.google.com/group/django-users/browse_thread/thread/bd5a6b329b009cfa
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...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
It depends a little on the exact use case your patch covers. If your
aggregate only covers an obscure edge case, I'd prefer to see it live
externally; but if you can make a case that it's a common use case (or
it's obvious that it is a common use case), then a suitably robust and
tested patch could be considered for core.
Yours,
Russ Magee %-)
Yours,
Russ Magee %-)