summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSage Abdullah <me@laymonage.com>2024-12-15 16:01:45 +0000
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-12-16 12:06:01 +0100
commitd7d711c68cc070d9b6962f43f97ece097162adcc (patch)
treec62e55926c88fc999cba8666d7595e054a1a4313 /docs
parentd36ad43f612295e2740fa26b7307d4041044ae3e (diff)
Refs #35718, Refs #32179 -- Moved JSONObject to django.db.models.functions.json.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/database-functions.txt55
1 files changed, 30 insertions, 25 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt
index eb08e160f7..f23585739e 100644
--- a/docs/ref/models/database-functions.txt
+++ b/docs/ref/models/database-functions.txt
@@ -163,31 +163,6 @@ and ``comment.modified``.
The PostgreSQL behavior can be emulated using ``Coalesce`` if you know
a sensible minimum value to provide as a default.
-``JSONObject``
---------------
-
-.. class:: JSONObject(**fields)
-
-Takes a list of key-value pairs and returns a JSON object containing those
-pairs.
-
-Usage example:
-
-.. code-block:: pycon
-
- >>> from django.db.models import F
- >>> from django.db.models.functions import JSONObject, Lower
- >>> Author.objects.create(name="Margaret Smith", alias="msmith", age=25)
- >>> author = Author.objects.annotate(
- ... json_object=JSONObject(
- ... name=Lower("name"),
- ... alias="alias",
- ... age=F("age") * 2,
- ... )
- ... ).get()
- >>> author.json_object
- {'name': 'margaret smith', 'alias': 'msmith', 'age': 50}
-
``Least``
---------
@@ -861,6 +836,36 @@ that deal with time-parts can be used with ``TimeField``:
2014-06-16 00:00:00+10:00 2
2016-01-01 04:00:00+11:00 1
+.. _json-functions:
+
+JSON Functions
+==============
+
+``JSONObject``
+--------------
+
+.. class:: JSONObject(**fields)
+
+Takes a list of key-value pairs and returns a JSON object containing those
+pairs.
+
+Usage example:
+
+.. code-block:: pycon
+
+ >>> from django.db.models import F
+ >>> from django.db.models.functions import JSONObject, Lower
+ >>> Author.objects.create(name="Margaret Smith", alias="msmith", age=25)
+ >>> author = Author.objects.annotate(
+ ... json_object=JSONObject(
+ ... name=Lower("name"),
+ ... alias="alias",
+ ... age=F("age") * 2,
+ ... )
+ ... ).get()
+ >>> author.json_object
+ {'name': 'margaret smith', 'alias': 'msmith', 'age': 50}
+
.. _math-functions:
Math Functions