mirror of
https://github.com/django/django.git
synced 2025-03-07 07:52:31 +00:00
Fixed #27414 -- Doc'd that F() expressions on relations return pk values.
This commit is contained in:
parent
e7dfb60353
commit
f8fab6f902
@ -214,6 +214,15 @@ directly support ``output_field`` you will need to wrap the expression with
|
|||||||
expires=ExpressionWrapper(
|
expires=ExpressionWrapper(
|
||||||
F('active_at') + F('duration'), output_field=DateTimeField()))
|
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:
|
||||||
|
|
||||||
``Func()`` expressions
|
``Func()`` expressions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user