Кэширует ли Django связанные поля ForeignKey и ManyToManyField после первого обращения к ним?

Учитывая следующую модель, кэширует ли Django связанные объекты после первого обращения к ним?

class Post(models.Model):
    authors = models.ManyToManyField(User)
    category = models.ForeignKey(Category)

Например:

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

Примечание: сейчас работаю с Django 1.3, но полезно знать, что доступно в других версиях.

10
задан bpscott 30 November 2011 в 15:25
поделиться