Opened 8 years ago

Closed 8 years ago

#4997 closed (wontfix)

[patch] Add group_by() support to QuerySets

Reported by: David Cramer <dcramer@…> Owned by: adrian
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: UI/UX:


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@…> 8 years ago. (1.4 KB) - added by David Cramer <dcramer@…> 8 years ago.

Download all attachments as: .zip

Change History (4)

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

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


comment:1 Changed 8 years ago by anonymous

  • Cc bharring@… added
  • Needs documentation set
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 8 years ago by russellm

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

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