summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/models/database-functions.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt
index 2bc95ff6e5..cd2d1ee368 100644
--- a/docs/ref/models/database-functions.txt
+++ b/docs/ref/models/database-functions.txt
@@ -23,6 +23,24 @@ We don't usually recommend allowing ``null=True`` for ``CharField`` since this
allows the field to have two "empty values", but it's important for the
``Coalesce`` example below.
+``Cast``
+========
+
+.. class:: Cast(expression, output_field)
+
+.. versionadded:: 1.10
+
+Forces the result type of ``expression`` to be the one from ``output_field``.
+
+Usage example::
+
+ >>> from django.db.models import FloatField
+ >>> from django.db.models.functions import Cast
+ >>> Value.objects.create(integer=4)
+ >>> value = Value.objects.annotate(as_float=Cast('integer', FloatField)).get()
+ >>> print(value.as_float)
+ 4.0
+
``Coalesce``
============