Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
5d923f2d
Kaydet (Commit)
5d923f2d
authored
Nis 20, 2018
tarafından
drd0013
Kaydeden (comit)
Tim Graham
Nis 20, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29313 -- Doc'd how to use F() to sort null values.
üst
534d8d87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
expressions.txt
docs/ref/models/expressions.txt
+17
-0
No files found.
docs/ref/models/expressions.txt
Dosyayı görüntüle @
5d923f2d
...
@@ -228,6 +228,21 @@ primary key value rather than a model instance::
...
@@ -228,6 +228,21 @@ primary key value rather than a model instance::
>> car.built_by
>> car.built_by
3
3
.. _using-f-to-sort-null-values:
Using ``F()`` to sort null values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Use ``F()`` and the ``nulls_first`` or ``nulls_last`` keyword argument to
:meth:`.Expression.asc` or :meth:`~.Expression.desc` to control the ordering of
a field's null values. By default, the ordering depends on your database.
For example, to sort companies that haven't been contacted (``last_contacted``
is null) after companies that have been contacted::
from django.db.models import F
Company.object.order_by(F('last_contacted').desc(nulls_last=True))
.. _func-expressions:
.. _func-expressions:
``Func()`` expressions
``Func()`` expressions
...
@@ -971,12 +986,14 @@ calling the appropriate methods on the wrapped expression.
...
@@ -971,12 +986,14 @@ calling the appropriate methods on the wrapped expression.
Returns the expression ready to be sorted in ascending order.
Returns the expression ready to be sorted in ascending order.
``nulls_first`` and ``nulls_last`` define how null values are sorted.
``nulls_first`` and ``nulls_last`` define how null values are sorted.
See :ref:`using-f-to-sort-null-values` for example usage.
.. method:: desc(nulls_first=False, nulls_last=False)
.. method:: desc(nulls_first=False, nulls_last=False)
Returns the expression ready to be sorted in descending order.
Returns the expression ready to be sorted in descending order.
``nulls_first`` and ``nulls_last`` define how null values are sorted.
``nulls_first`` and ``nulls_last`` define how null values are sorted.
See :ref:`using-f-to-sort-null-values` for example usage.
.. method:: reverse_ordering()
.. method:: reverse_ordering()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment