Opened 10 years ago

Closed 2 years ago

Last modified 7 months ago

#11557 closed New feature (fixed)

get_latest_by should support multiple columns via tuple like ordering

Reported by: Forest Bond Owned by: François Freitag
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: get_latest_by ordering
Cc: Forest Bond, denilsonsa@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The ordering attribute of the Meta class is a tuple so that the default ordering can use multiple columns. It would be nice if get_latest_by was the same way. However, it currently must be a string specifying a single column.

This is especially important when specifying both, since you would typically want the latest item to correspond with the last item in a list ordered according to ordering.

Attachments (2)

django-get-latest-by-tuple.diff (1.9 KB) - added by Forest Bond 10 years ago.
Patch implementing requested feature.
django-11557.patch (6.7 KB) - added by Forest Bond 9 years ago.
Improved patch with documentation.

Download all attachments as: .zip

Change History (14)

Changed 10 years ago by Forest Bond

Patch implementing requested feature.

comment:1 Changed 10 years ago by Forest Bond

Component: UncategorizedDatabase layer (models, ORM)
Has patch: set
Keywords: get_latest_by ordering added

comment:2 Changed 10 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:3 Changed 9 years ago by Forest Bond

Cc: Forest Bond added

Is my patch acceptable? It'd be great to see this in 1.3.

comment:4 Changed 9 years ago by Forest Bond

Attaching an improved patch with documentation.

Changed 9 years ago by Forest Bond

Attachment: django-11557.patch added

Improved patch with documentation.

comment:5 Changed 8 years ago by Julien Phalip

Severity: Normal
Type: New feature

comment:6 Changed 8 years ago by dmclain

Easy pickings: unset
Patch needs improvement: set
Triage Stage: AcceptedDesign decision needed

The patch no longer applies cleanly

comment:7 Changed 8 years ago by dmclain

Triage Stage: Design decision neededAccepted

Didn't mean to sent to DDN, changing back to Accepted.

comment:8 Changed 8 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:9 Changed 5 years ago by Denilson Figueiredo de Sá

Cc: denilsonsa@… added

comment:10 Changed 2 years ago by François Freitag

Owner: changed from nobody to François Freitag
Patch needs improvement: unset
Status: newassigned
Version: 1.0master

comment:11 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In ad4a8ac:

Fixed #11557 -- Added support for a list of fields in Meta.get_latest_by and QuerySet.earliest()/latest().

comment:12 Changed 7 months ago by Tim Graham <timograham@…>

In 1fecde6:

Refs #11557 -- Removed the field_name keyword argument to QuerySet.earliest() and latest().

Per deprecation timeline.

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