On Feb 2, 9:05 pm, nsitarz <nsit...@gmail.com> wrote:
> Hey,
>
> Back when the ORM aggregate support was a patch in trac I used to
> create custom aggregate objects that looked like this:
>
> class Date(Aggregate):
> pass
>
> class DateHour(Aggregate):
> def __init__(self, lookup):
> super(DateHour, self).__init__(lookup)
> self.sql_template = '(DATE(${field}) + INTERVAL HOUR(${field})
> HOUR)'
>
> However now that aggregate support has made its way into trunk the api
> seems to have changed a bit. After reading the aggregate module it
> looks to me like I'd have to reimplement the Aggregate class myself in
> order to have this same kind of functionality. Is there a supported
> way of creating custom aggregate classes for use with the trunk ORM?
>
> I'd appreciate any help that anybody can offer on this.
Aggregates were refactored so that they involve 2 classes, 1
implements the public API, and the other implements the SQL bit.
Basically look here:
http://code.djangoproject.com/browser/django/trunk/django/db/models/aggregates.py#L26
for what you're public API bit should be(instead of pulling the clsas
out of the aggreagetes module it can just refer to te specific class
it goes with). And then here:
http://code.djangoproject.com/browser/django/trunk/django/db/models/sql/aggregates.py
for what the SQL backened's API is.
Alex
--~--~---------~--~----~------------~-------~--~----~
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
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---