Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#18875 closed Cleanup/optimization (fixed)

Document that models.Options.get_latest_by supports integers

Reported by: Adam Nelson Owned by: Dan Loewenherz
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In the documentation (https://docs.djangoproject.com/en/dev/ref/models/options/#django.db.models.Options.get_latest_by) , models.Options.get_latest_by specifies that DateField and DateTimeField are the only types supported for get_latest_by. In fact, any orderable field type is supported (https://github.com/django/django/blob/master/django/db/models/query.py#L477). The documentation should simply replace "The name of a DateField or DateTimeField in the model." with "The name of a field in the model - typically a DateField, DateTimeField, or IntegerField."

Using get_latest_by('id') is very useful for large tables where reverse sorting by 'id' is a proxy for latest.

Change History (3)

comment:1 by Dan Loewenherz, 12 years ago

Has patch: set
Owner: changed from nobody to Dan Loewenherz
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by Dan Loewenherz <dloewenherz@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In [09e3d364b922510f4c14a4d843e59c37304fa1a7]:

specify any orderable field can be specified in get_latest_by, closes #18875

comment:3 by Alex Gaynor <alex.gaynor@…>, 12 years ago

In [cceff73acd7d82904a4b9c28dea2448f09c941b0]:

Merge pull request #335 from dlo/tickets/18875

specify any orderable field can be specified in get_latest_by, closes #18875

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