【发布时间】:2012-12-30 08:05:37
【问题描述】:
我在models.py:
class Team(models.Model):
x = models.IntegerField()
y = models.IntegerField()
a = models.IntegerField()
b = models.IntegerField()
def get_stat(self):
return {
'xy': self.x + self.y,
'ab': self.a + self.b
}
stat = property(get_stat)
在team.html 我有:
xy stat: {{ team.stat.xy }}
ab stat: {{ team.stat.ab }}
问题是:“django 每次我调用stat 时都会执行get_stat 函数还是缓存结果?”
【问题讨论】:
标签: python django templates caching