diff options
author | Tsering <hour1hr@gmail.com> | 2016-04-23 16:38:57 -0400 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-06-28 16:27:44 -0400 |
commit | 67c60cce7073762106bca186669af0fe1f588d15 (patch) | |
tree | fb3eda9cfa05cf0d5b48c8ade881dbd611a6ae05 /docs | |
parent | e1d83c2f3f617e3c5cf871ecd8942286122ec2b7 (diff) | |
download | django-67c60cce7073762106bca186669af0fe1f588d15.tar.gz |
[1.9.x] Refs #23386 -- Documented that F() expressions are applied on each model.save()
Backport of fc4b4fd5850989458d6e54de12a29b2e40e94ce8 from master
Diffstat (limited to 'docs')
-rw-r--r-- | docs/ref/models/expressions.txt | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt index 7a1945a948..4eb16e361f 100644 --- a/docs/ref/models/expressions.txt +++ b/docs/ref/models/expressions.txt @@ -174,6 +174,22 @@ robust: it will only ever update the field based on the value of the field in the database when the :meth:`~Model.save()` or ``update()`` is executed, rather than based on its value when the instance was retrieved. +``F()`` assignments persist after ``Model.save()`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``F()`` objects assigned to model fields persist after saving the model +instance and will be applied on each :meth:`~Model.save()`. For example:: + + reporter = Reporters.objects.get(name='Tintin') + reporter.stories_filed = F('stories_filed') + 1 + reporter.save() + + reporter.name = 'Tintin Jr.' + reporter.save() + +``stories_filed`` will be updated twice in this case. If it's initially ``1``, +the final value will be ``3``. + Using ``F()`` in filters ~~~~~~~~~~~~~~~~~~~~~~~~ |