#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 , 13 years ago
| Has patch: | set |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
PR sent.
https://github.com/django/django/pull/335