diff options
| author | Chad Shryock <chad@isl.co> | 2016-06-02 10:52:58 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-06-02 19:42:08 -0400 |
| commit | e6c5e68acd4bff90e371fd148ed6976e147692ad (patch) | |
| tree | ac8c516d30e3af590327fde79e5dbe380ee9f285 /docs/ref | |
| parent | c7b1b81352533be9b7f4637c12219f59c0964a82 (diff) | |
Fixed #26526 -- Documented QuerySet.latest()'s dependency on database ordering.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/querysets.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index e8753971c3..34ec26466c 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1952,6 +1952,17 @@ given parameters. Note that ``earliest()`` and ``latest()`` exist purely for convenience and readability. +.. admonition:: ``earliest()`` and ``latest()`` may return instances with null dates. + + Since ordering is delegated to the database, results on fields that allow + null values may be ordered differently if you use different databases. For + example, PostgreSQL and MySQL sort null values as if they are higher than + non-null values, while SQLite does the opposite. + + You may want to filter out null values:: + + Entry.objects.filter(pub_date__isnull=False).latest('pub_date') + ``earliest()`` ~~~~~~~~~~~~~~ |
