diff options
| author | Bryan Helmig <bryan@zapier.com> | 2017-08-10 11:54:19 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-08-11 10:14:08 -0400 |
| commit | 93b53fb942c2b16e2f7079b86d18bcf800a3f368 (patch) | |
| tree | 8d30c96521cf6cd90f5dc9300edf16b658f2c1dc /docs/ref | |
| parent | fe51017efdc3f26c94c83fe5930b14d71e1bb380 (diff) | |
[1.11.x] Made the @cached_property example more consistent.
Backport of 68f0bcb012fefffcf94b25dedd02c061a7544041 from master
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/utils.txt | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 4ad645f958..9910c61116 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -477,16 +477,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:: |
