title: Tastypie optimization with prefetch_related and ModelResources
body: <p>I have the following ModelResource:</p>
  
  <pre><code>class DivisionsResource(ModelResource):
      plants = fields.ToManyField('plants.api.resources.PlantsResource', 'plant_set', full = True)
  
      class Meta:
          queryset = Division.objects.all().prefetch_related('plant_set')
          allowed_method = ['get']
          filtering = {
                      "name": ('istartswith')
                  }
  
  
  class PlantsResource(ModelResource):
      picture = fields.ToOneField('files.api.resources.PlantPictureResource', 'picture', full=True)
      production_lines = fields.ToManyField('production_lines.api.resources.ProductionLinesResource','productionline_set', full=True, null=True)
  
      class Meta:
          queryset = Plant.objects.select_related('picture').all().prefetch_related('productionline_set')
          allowed_methods = ['get']
  </code></pre>
  
  <p>However, if I call the "divisions" resource and I look at the SQL queries, it doesn't do the prefetch_related and select_related within the <strong>Plants Resource</strong>. It goes and select the productionline_set and picture for each individual plant, instead of doing a <strong>in</strong> SQL query. Why is that? </p>
  
  <p>I found however that I could do something like this:</p>
  
  <pre><code>queryset = Division.objects.all().prefetch_related('plant_set', 'plant_set__picture','plant_set__productionline_set')
  </code></pre>
  
  <p>Do I have to do this for sure in the <strong>Divisions Model</strong>? It will be super long if the "prefetch" and "select_related" are not called when calling from parents..</p>