1
0
mirror of https://github.com/django/django.git synced 2025-04-08 23:46:43 +00:00

[1.10.x] Fixed #27414 -- Doc'd that F() expressions on relations return pk values.

Backport of f8fab6f90233c7114d642dfe01a4e6d4cb14ee7d from master
This commit is contained in:
Jop Reyntjes 2016-11-05 21:49:48 +00:00 committed by Tim Graham
parent bc74bc1f35
commit 89d960121d

View File

@ -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