summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-06-05 15:20:37 +0100
committerTim Graham <timograham@gmail.com>2016-03-29 08:14:33 -0400
commit03b6947728466e4e907487f30dd4dfec94a8eb2f (patch)
tree923a8045ea4b2cc686a072ccbfa1be73f9f5fa06 /docs
parent53361589905c7c07692cd77f398ce6cb5ac39779 (diff)
Fixed #24932 -- Added Cast database function.
Thanks Ian Foote for the initial patch.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/database-functions.txt18
-rw-r--r--docs/releases/1.10.txt2
2 files changed, 20 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``
============
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index 48a262362e..1d253bfe62 100644
--- a/docs/releases/1.10.txt
+++ b/docs/releases/1.10.txt
@@ -349,6 +349,8 @@ Models
* :meth:`QuerySet.bulk_create() <django.db.models.query.QuerySet.bulk_create>`
sets the primary key on objects when using PostgreSQL.
+* Added the :class:`~django.db.models.functions.Cast` database function.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~