mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #16211 -- Added logical NOT support to F expressions.
This commit is contained in:
parent
c01e76c95c
commit
a320aab512
7 changed files with 164 additions and 29 deletions
|
@ -255,6 +255,19 @@ is null) after companies that have been contacted::
|
|||
from django.db.models import F
|
||||
Company.objects.order_by(F('last_contacted').desc(nulls_last=True))
|
||||
|
||||
Using ``F()`` with logical operations
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 4.2
|
||||
|
||||
``F()`` expressions that output ``BooleanField`` can be logically negated with
|
||||
the inversion operator ``~F()``. For example, to swap the activation status of
|
||||
companies::
|
||||
|
||||
from django.db.models import F
|
||||
|
||||
Company.objects.update(is_active=~F('is_active'))
|
||||
|
||||
.. _func-expressions:
|
||||
|
||||
``Func()`` expressions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue