summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJop Reyntjes <jop.reyntjes@gmail.com>2016-11-05 21:49:48 +0000
committerTim Graham <timograham@gmail.com>2016-11-09 07:13:24 -0500
commit89d960121d97a3c2fc8bc768f75bc24f43838c6c (patch)
tree973ec78361240c588b699730939e1dbf6dfcb7fe /docs
parentbc74bc1f35e33b0f37cea76aae81840e067d7802 (diff)
[1.10.x] Fixed #27414 -- Doc'd that F() expressions on relations return pk values.
Backport of f8fab6f90233c7114d642dfe01a4e6d4cb14ee7d from master
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/expressions.txt9
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt
index 1038e886bb..245d8f7abc 100644
--- a/docs/ref/models/expressions.txt
+++ b/docs/ref/models/expressions.txt
@@ -218,6 +218,15 @@ directly support ``output_field`` you will need to wrap the expression with
expires=ExpressionWrapper(
F('active_at') + F('duration'), output_field=DateTimeField()))
+When referencing relational fields such as ``ForeignKey``, ``F()`` returns the
+primary key value rather than a model instance::
+
+ >> car = Company.objects.annotate(built_by=F('manufacturer'))[0]
+ >> car.manufacturer
+ <Manufacturer: Toyota>
+ >> car.built_by
+ 3
+
.. _func-expressions:
``Func()`` expressions