Wednesday, October 31, 2018

Re: Prepopulate blog in b.entry_set.all()[i].blog ?

It seems to be a bug as reported in The ForeignKey must use to_field to reproduce the problem.

On Saturday, October 20, 2018 at 4:38:51 AM UTC-4, Carsten Fuchs wrote:
Can anyone help please?

Am 2018-10-11 um 16:58 schrieb Carsten Fuchs:
> Dear Django group,
> with Django 1.11.15, using the example models Blog and Entry at
> <>
> for reference, I have code like this:
>      b = Blog.objects.get(name="...")
>      for e in b.entry_set.all():
>          print(
> Obviously, == b, but I found that for each e, the access to
> causes a subquery to fetch the blog object.
> While I understand the concepts of select_related() and
> prefetch_related(), I was surprised that the attributes are not
> prepopulated with b. Why is that and what is the proper way to fix the
> problem?
> Best regards,
> Carsten

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment