鉴于以下模型,Django是否在第一次访问后缓存相关对象?
class Post(models.Model):
authors = models.ManyToManyField(User)
category = models.ForeignKey(Category)
Run Code Online (Sandbox Code Playgroud)
例如:
post = Post.objects.get(id=1)
# as i understand this hits the database
authors1 = post.authors.all()
# does this his the database again?
authors2 = post.authors.all()
# as i understand this hits the database
category1 = post.category
# does this hit the database again?
category2 = post.category
Run Code Online (Sandbox Code Playgroud)
注意:目前正在使用Django 1.3,但很高兴知道其他版本中可用的内容.