summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorsamruddhiDharankar <samruddhee.dharankar@gmail.com>2025-03-01 14:53:20 -0800
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-03-10 12:55:50 +0100
commit930d9c2fd9755ac5a5fd6c826a3606590e0c48d5 (patch)
treea26cd51ddde5578cac56379e05998c29fa63e65f /docs
parent4c7b737b309ebcc1d2264572e1fe835798acd18a (diff)
[5.2.x] Fixed #36066 -- Documented that Q objects can be used directly in annotations.
Backport of 9120a19c4ecb643111b073dd1069e6b410a03c23 from main.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/querysets.txt12
1 files changed, 8 insertions, 4 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index ec27936cdb..5bd23262ef 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -258,10 +258,14 @@ you can use :class:`Q objects <django.db.models.Q>` (``*args``).
.. method:: annotate(*args, **kwargs)
Annotates each object in the ``QuerySet`` with the provided list of :doc:`query
-expressions </ref/models/expressions>`. An expression may be a simple value, a
-reference to a field on the model (or any related models), or an aggregate
-expression (averages, sums, etc.) that has been computed over the objects that
-are related to the objects in the ``QuerySet``.
+expressions </ref/models/expressions>` or :class:`~django.db.models.Q` objects.
+Each object can be annotated with:
+
+* a simple value, via ``Value()``;
+* a reference to a field on the model (or any related models), via ``F()``;
+* a boolean, via ``Q()``; or
+* a result from an aggregate expression (averages, sums, etc.) computed over
+ the objects that are related to the objects in the ``QuerySet``.
Each argument to ``annotate()`` is an annotation that will be added
to each object in the ``QuerySet`` that is returned.