summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2015-03-16 16:11:03 +1100
committerTim Graham <timograham@gmail.com>2015-03-16 11:54:27 -0400
commit820381d38bc02ea8b92837ce869e7332a7db9913 (patch)
tree08298c18627c5300b2a852c5155b09e9191d0ef3
parent937643a1f215d7d2063b256269d757a2ee316f07 (diff)
Fixed #24486 -- Documented method to provide output_field to mixed F expressions
-rw-r--r--docs/ref/models/expressions.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt
index 6632e4e94d..1722daa981 100644
--- a/docs/ref/models/expressions.txt
+++ b/docs/ref/models/expressions.txt
@@ -274,6 +274,17 @@ should define the desired ``output_field``. For example, adding an
``IntegerField()`` and a ``FloatField()`` together should probably have
``output_field=FloatField()`` defined.
+.. note::
+
+ When you need to define the ``output_field`` for ``F`` expression
+ arithmetic between different types, it's necessary to surround the
+ expression in another expression::
+
+ from django.db.models import DateTimeField, ExpressionNode, F
+
+ Race.objects.annotate(finish=ExpressionNode(
+ F('start') + F('duration'), output_field=DateTimeField()))
+
.. versionchanged:: 1.8
``output_field`` is a new parameter.