summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Shryock <chad@isl.co>2016-06-02 10:52:58 -0700
committerTim Graham <timograham@gmail.com>2016-06-02 19:42:57 -0400
commitcd4246aab1740d77fa6ebd66c7d2053634501598 (patch)
tree216cf89cab2e6448bf1091f3b2936c5a6e5e282b
parent3eb31867bb25d462634255e187001c0fffe2a032 (diff)
[1.10.x] Fixed #26526 -- Documented QuerySet.latest()'s dependency on database ordering.
Backport of e6c5e68acd4bff90e371fd148ed6976e147692ad from master
-rw-r--r--docs/ref/models/querysets.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 8ce6d501ce..c348db182b 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -1956,6 +1956,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()``
~~~~~~~~~~~~~~