diff options
| author | Jop Reyntjes <jop.reyntjes@gmail.com> | 2016-11-05 21:49:48 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-11-09 07:11:46 -0500 |
| commit | f8fab6f90233c7114d642dfe01a4e6d4cb14ee7d (patch) | |
| tree | 65f8c6d08412ffcba7e2422f2ed5b5d08a10a7ba /docs/ref | |
| parent | e7dfb60353686e9dc62d340e96b017deaa248638 (diff) | |
Fixed #27414 -- Doc'd that F() expressions on relations return pk values.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/expressions.txt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt index 66bb905147..daf8440512 100644 --- a/docs/ref/models/expressions.txt +++ b/docs/ref/models/expressions.txt @@ -214,6 +214,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 |
