Dear Django group,
with Django 1.11.15, using the example models Blog and Entry at
<
https://docs.djangoproject.com/en/2.1/topics/db/queries/#related-objects> for
reference, I have code like this:
b = Blog.objects.get(name="...")
for e in b.entry_set.all():
print(e.blog)
Obviously, e.blog == b, but I found that for each e, the access to e.blog causes
a subquery to fetch the blog object.
While I understand the concepts of select_related() and prefetch_related(), I
was surprised that the e.blog attributes are not prepopulated with b. Why is
that and what is the proper way to fix the problem?
Best regards,
Carsten