Opened 5 years ago

Last modified 3 years ago

#11557 new New feature

get_latest_by should support multiple columns via tuple like ordering

Reported by: forest Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Normal Keywords: get_latest_by ordering
Cc: forest Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
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 5 years ago.
Patch implementing requested feature.
django-11557.patch (6.7 KB) - added by forest 4 years ago.
Improved patch with documentation.

Download all attachments as: .zip

Change History (10)

Changed 5 years ago by forest

Patch implementing requested feature.

comment:1 Changed 5 years ago by forest

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Has patch set
  • Keywords get_latest_by ordering added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by forest

  • Cc forest added

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

comment:4 Changed 4 years ago by forest

Attaching an improved patch with documentation.

Changed 4 years ago by forest

Improved patch with documentation.

comment:5 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:6 Changed 3 years ago by dmclain

  • Easy pickings unset
  • Patch needs improvement set
  • Triage Stage changed from Accepted to Design decision needed

The patch no longer applies cleanly

comment:7 Changed 3 years ago by dmclain

  • Triage Stage changed from Design decision needed to Accepted

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

comment:8 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

Add Comment

Modify Ticket

Change Properties
<Author field>
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.