If I have the following models:
class Fubar(models.Model): name = models.CharField() class Related(models.Model): fubar = models.ForeignKey(Fubar)
I would expect ORM to magically cache the parent Fubar if I accessed Related to .related_set:
fubar = Fubar.objects.all()[0] related = fubar.related_set.all()[0] related.fubar
This leads to 3 queries, where I expect it to lead to only 2, since related.fubar can be optimized in this context to be the same object that I called the LinkedManager.
source share