Opened 15 years ago

Closed 7 years ago

Last modified 6 years 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: dev
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

Description

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 15 years ago.
Patch implementing requested feature.
django-11557.patch (6.7 KB ) - added by Forest Bond 14 years ago.
Improved patch with documentation.

Download all attachments as: .zip

Change History (14)

by Forest Bond, 15 years ago

Patch implementing requested feature.

comment:1 by Forest Bond, 15 years ago

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

comment:2 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Forest Bond, 15 years ago

Cc: Forest Bond added

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

comment:4 by Forest Bond, 14 years ago

Attaching an improved patch with documentation.

by Forest Bond, 14 years ago

Attachment: django-11557.patch added

Improved patch with documentation.

comment:5 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:6 by dmclain, 14 years ago

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

The patch no longer applies cleanly

comment:7 by dmclain, 14 years ago

Triage Stage: Design decision neededAccepted

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

comment:8 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:9 by Denilson Figueiredo de Sá, 10 years ago

Cc: denilsonsa@… added

comment:10 by François Freitag, 7 years ago

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

comment:11 by Tim Graham <timograham@…>, 7 years ago

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 by Tim Graham <timograham@…>, 6 years ago

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