Reputation: 2837
I have several models with one-to-many relationships. In my management commands I need to iterate over all entities multiple times. I.e. I have multiple loops like this:
for childEntity in dbObj.childEntities.all():
....
Does Django use session cache for dbObj.childEntities.all()
? Or I need to cache results somehow?
Upvotes: 0
Views: 242
Reputation: 600059
No, not by default. You can enable it by using prefetch_related
.
Upvotes: 1