summaryrefslogtreecommitdiff
path: root/docs/ref/models
diff options
context:
space:
mode:
authorPaul Wayper <paulway@redhat.com>2019-03-14 14:08:02 +1100
committerTim Graham <timograham@gmail.com>2019-03-18 11:11:55 -0400
commita48c0180f56316b0e32bf2f4a858d1e097eb1863 (patch)
treed373f1fbf03497a5b0e4f64da82a68c2726312cc /docs/ref/models
parent2a423041119495196ff280b8f4a92639cb02ba98 (diff)
downloaddjango-a48c0180f56316b0e32bf2f4a858d1e097eb1863.tar.gz
[2.2.x] Fixed #30253 -- Doc'd how to order nulls in QuerySet.order_by().
Backport of 1025e764291167f2f34a4d55bd3d043836e74250 from master.
Diffstat (limited to 'docs/ref/models')
-rw-r--r--docs/ref/models/querysets.txt6
1 files changed, 5 insertions, 1 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 444c428583..51bb453b97 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -312,10 +312,14 @@ identical to::
Entry.objects.order_by('blog__name')
You can also order by :doc:`query expressions </ref/models/expressions>` by
-calling ``asc()`` or ``desc()`` on the expression::
+calling :meth:`~.Expression.asc` or :meth:`~.Expression.desc` on the
+expression::
Entry.objects.order_by(Coalesce('summary', 'headline').desc())
+:meth:`~.Expression.asc` and :meth:`~.Expression.desc` have arguments
+(``nulls_first`` and ``nulls_last``) that control how null values are sorted.
+
Be cautious when ordering by fields in related models if you are also using
:meth:`distinct()`. See the note in :meth:`distinct` for an explanation of how
related model ordering can change the expected results.