Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
68f0bcb0
Kaydet (Commit)
68f0bcb0
authored
Agu 10, 2017
tarafından
Bryan Helmig
Kaydeden (comit)
Tim Graham
Agu 11, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Made the @cached_property example more consistent.
üst
9ecf2803
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
utils.txt
docs/ref/utils.txt
+7
-7
No files found.
docs/ref/utils.txt
Dosyayı görüntüle @
68f0bcb0
...
@@ -471,16 +471,16 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
...
@@ -471,16 +471,16 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
{% for friend in person.friends %}
{% for friend in person.friends %}
Here, ``friends()`` will be called twice. Since the instance ``person`` in
Here, ``friends()`` will be called twice. Since the instance ``person`` in
the view and the template are the same,
``@cached_property`` can avoi
d
the view and the template are the same,
decorating the ``friends()`` metho
d
that::
with ``@cached_property`` can avoid
that::
from django.utils.functional import cached_property
from django.utils.functional import cached_property
@cached_property
class Person(models.Model):
def friends(self):
# expensive computation
@cached_property
...
def friends(self):
return friends
...
Note that as the method is now a property, in Python code it will need to
Note that as the method is now a property, in Python code it will need to
be invoked appropriately::
be invoked appropriately::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment