Opened 8 years ago

Closed 7 years ago

#1435 closed enhancement (duplicate)

[patch] Add aggregate function support.

Reported by: rock@… Owned by: adrian
Component: Database layer (models, ORM) Version: magic-removal
Severity: normal Keywords: aggregate sum count min max stddev avg
Cc: gary.wilson@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: UI/UX:

Attachments (2)

agg_funcs.diff (16.0 KB) - added by jacob 8 years ago.
aggr_functions-r3897.diff (13.6 KB) - added by dp_wiz 8 years ago.
updated patch for r3897 of trunk

Download all attachments as: .zip

Change History (12)

comment:1 Changed 8 years ago by jacob

  • Description modified (diff)
  • Summary changed from Add Aggregate Function support. to [path] Add aggregate function support.

Changed 8 years ago by jacob

comment:2 Changed 8 years ago by anonymous

  • Summary changed from [path] Add aggregate function support. to [patch] Add aggregate function support.

comment:3 Changed 8 years ago by russellm

(at the suggestion of Stephen Newey <stephen.newey@…>) One piece of aggregate functionality that doesn't directly map to an SQL query is 'exists' - i.e., select all objects where at least one object exists in the relation. This can be currently 'faked' using a query like:


but it would be nice if an 'exists' query clause were to be included as part of the aggregate effort. Something like:


or, more generally:


selecting all topics with more than 5 articles.

comment:4 Changed 8 years ago by russellm

Examples again, this time with wikiformatting:




comment:5 Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • milestone changed from Version 0.92 to Version 1.0

0.92 is long gone.

Changed 8 years ago by dp_wiz

updated patch for r3897 of trunk

comment:6 Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • Cc gary.wilson@… added

comment:7 Changed 7 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

comment:8 Changed 7 years ago by Simon G. <dev@…>

  • Needs documentation set
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

I think this is close to being ready, but needs documentation and testing.

comment:9 Changed 7 years ago by russellm

  • Triage Stage changed from Accepted to Design decision needed

This topic comes up from time to time in the django-users and django-dev mailing lists; while aggregate functions are something that we should be striving to add to Django, I am not happy with the patch suggested in this proposal.

The archives contain many discussions in which I have talked about my reservations on this patch;
This thread:

has at least one proposal for a more wide ranging approach.

comment:10 Changed 7 years ago by russellm

  • Resolution set to duplicate
  • Status changed from new to closed

I'm closing this ticket in favour of #3566, which is a duplicate that seems to have a larger discussion around it.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.