Opened 12 years ago

Closed 12 years ago

#4997 closed (wontfix)

[patch] Add group_by() support to QuerySets

Reported by: David Cramer <dcramer@…> Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: Keywords: group_by, orm
Cc: bharring@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The following adds the ability to do .group_by() on QuerySet objects.

# Should return one result unique to each foreignkey


# Returns the numbers of results available. Calls a DISTINCT() query on group_by fields


Attachments (2) (4.2 KB) - added by David Cramer <dcramer@…> 12 years ago. (1.4 KB) - added by David Cramer <dcramer@…> 12 years ago.

Download all attachments as: .zip

Change History (4)

Changed 12 years ago by David Cramer <dcramer@…>

Attachment: added

Changed 12 years ago by David Cramer <dcramer@…>

Attachment: added


comment:1 Changed 12 years ago by anonymous

Cc: bharring@… added
Needs documentation: set

comment:2 Changed 12 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

The idea of a 'group_by' and 'having' clause has been floated many times before, and has been rejected in preference of an 'aggregations' framework that provides a higher level, ORM-like interface (rather than a SQL like interface) to the the ideas that group_by and having expose. See Ticket #3566 for details on current thinking.

Adding this feature is waiting on a refactor of the internals of the query engine. Malcolm is in the process of doing this refactor; any patch against is likely to be rendered invalid in the near future.

Note: See TracTickets for help on using tickets.
Back to Top