title: Prefetch related after many-to-one relation
body: <p>I have the following (simplified) model structure:</p>
  
  <pre><code>class Article(Model):
      @property
      def article_number(self) -&gt; str:
          return self.attributes.get(masterdata_type__code='article_number').value
  
  class Attribute(Model):
      article = ForeignKey(Article, null=True, blank=True, related_name='attributes')
      masterdata_type = ForeignKey(Type, related_name='attributes')
      value = CharField(max_length=256, blank=True, db_index=True)
  
  class Type(Model):
      code = models.CharField(max_length=32)
  </code></pre>
  
  <p>In the admin panel, I want to show a list of 100s of articles and show its article_number. This now result in 100s of database calls (which I can see using Silk monitoring), so I want to prefetch those objects. I tried the following solutions in the admin panel, but all didn't work. What is the proper way to reduce number of database calls here?</p>
  
  <p>I am using Django 1.8.14, with a PostgreSQL backend.</p>
  
  <p><strong>Solutions that don't work:</strong></p>
  
  <pre><code>def get_queryset(self, request):
      queryset = super(ArticleSetAdmin, self).get_queryset(request)
      return queryset.prefetch_related('attributes__masterdata_type')
  </code></pre>
  
  <p>Still 100s of database calls.</p>
  
  <pre><code>def get_queryset(self, request):
      queryset = super(ArticleSetAdmin, self).get_queryset(request)
      return queryset.prefetch_related(
          Prefetch('attributes', queryset=Attribute.objects.select_related('masterdata_type')))
  </code></pre>
  
  <p>Still 100s of database calls.</p>
  
  <pre><code>def get_queryset(self, request):
      queryset = super(ArticleSetAdmin, self).get_queryset(request)
      return queryset.prefetch_related(
          Prefetch('attributes', queryset=Attribute.objects.prefetch_related('masterdata_type')))
  </code></pre>
  
  <p>Still 100s of database calls.</p>
  
  <pre><code>def get_queryset(self, request):
      queryset = super(ArticleSetAdmin, self).get_queryset(request)
      return queryset.select_related('attributes__masterdata_type')
  </code></pre>
  
  <p>Error, since attributes is Many-to-One relationship to Article.</p>