Opened 12 years ago
Last modified 8 years ago
#19842 new Cleanup/optimization
annotate()-based solution to distinct and order_by problem
Reported by: | jogwen | Owned by: | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | avani9330 | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Note about how distinct may not work when ordering by related model fields could point the reader at this solution http://archlinux.me/dusty/2010/12/07/django-dont-use-distinct-and-order_by-across-relations/, using annotate().
Attachments (3)
Change History (24)
comment:1 by , 12 years ago
Needs documentation: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 12 years ago
Owner: | changed from | to
---|
comment:3 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 12 years ago
Owner: | changed from | to
---|
I also came accross this problem. I will try to put this suggestion in the Documentation as part of the DjangoCon Euro 2013 sprints.
comment:5 by , 12 years ago
Owner: | changed from | to
---|
by , 12 years ago
Attachment: | add_annotate_suggestion.patch added |
---|
comment:6 by , 12 years ago
Has patch: | set |
---|
comment:9 by , 12 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:10 by , 12 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
The documentation should be improved with an example, as suggested by @timgraham
by , 12 years ago
Attachment: | add_annotate_suggestion.2.patch added |
---|
comment:12 by , 12 years ago
Patch needs improvement: | set |
---|
comment:13 by , 11 years ago
Easy pickings: | unset |
---|---|
Owner: | removed |
Status: | assigned → new |
follow-up: 15 comment:14 by , 11 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:15 by , 11 years ago
Cc: | added |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:16 by , 11 years ago
Patch needs improvement: | unset |
---|
comment:17 by , 11 years ago
Needs documentation: | unset |
---|
comment:18 by , 11 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
comment:20 by , 11 years ago
Patch needs improvement: | set |
---|
comment:21 by , 8 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
Version: | 1.4 → master |
Note:
See TracTickets
for help on using tickets.
I think it's probably true that many cases of people trying to use
distinct
andorder_by
on related fields together would be solved byannotate
. It wouldn't hurt to mentionannotate
in that note.