summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorBryan Helmig <bryan@zapier.com>2017-08-10 11:54:19 -0400
committerTim Graham <timograham@gmail.com>2017-08-11 09:51:49 -0400
commit68f0bcb012fefffcf94b25dedd02c061a7544041 (patch)
treec5446527cc313c9696ff0c40416dda9610fc9d0b /docs/ref
parent9ecf2803943a3537f101ad4530d599f5edde651d (diff)
Made the @cached_property example more consistent.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/utils.txt14
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index 93a4715793..fef97530de 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -471,16 +471,16 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
{% for friend in person.friends %}
Here, ``friends()`` will be called twice. Since the instance ``person`` in
- the view and the template are the same, ``@cached_property`` can avoid
- that::
+ the view and the template are the same, decorating the ``friends()`` method
+ with ``@cached_property`` can avoid that::
from django.utils.functional import cached_property
- @cached_property
- def friends(self):
- # expensive computation
- ...
- return friends
+ class Person(models.Model):
+
+ @cached_property
+ def friends(self):
+ ...
Note that as the method is now a property, in Python code it will need to
be invoked appropriately::