diff options
| author | David Wobrock <david.wobrock@gmail.com> | 2022-09-26 22:59:25 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-10-31 09:55:51 +0100 |
| commit | a320aab5129f4019b3c1d28b7a3b509582bc56f9 (patch) | |
| tree | 31d140537fbf59616871a04eeb4d19fde54761f9 /docs | |
| parent | c01e76c95caa1bd2995f1b6c186cbe8726c92ef9 (diff) | |
Fixed #16211 -- Added logical NOT support to F expressions.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/expressions.txt | 13 | ||||
| -rw-r--r-- | docs/releases/4.2.txt | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt index ccd18670b1..e1edad2e4d 100644 --- a/docs/ref/models/expressions.txt +++ b/docs/ref/models/expressions.txt @@ -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 diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 58e4bd12ac..4f7bda7080 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -236,6 +236,9 @@ Models * :class:`~django.db.models.functions.Now` now supports microsecond precision on MySQL and millisecond precision on SQLite. +* :class:`F() <django.db.models.F>` expressions that output ``BooleanField`` + can now be negated using ``~F()`` (inversion operator). + Requests and Responses ~~~~~~~~~~~~~~~~~~~~~~ @@ -345,6 +348,9 @@ Miscellaneous * The minimum supported version of ``sqlparse`` is increased from 0.2.2 to 0.2.3. +* The undocumented ``negated`` parameter of the + :class:`~django.db.models.Exists` expression is removed. + .. _deprecated-features-4.2: Features deprecated in 4.2 |
