title: Django .values_list() alternative that returns a QuerySet for a ForeignKey field's model?
body: <p>I'm looking for a clean way to convert one type of QuerySet to another based on a models ForeignKey field, so basically something like a <code>.values_list('my_fk', flat=True)</code> but returning a proper QuerySet instead of a values_list() variant.</p>
  
  <p>For example:</p>
  
  <pre><code>class Parent(models.Model):
      child = models.ForeignKey(Child)
      ...
  
  children_qs = Parent.objects.filter(...).theMagicMethod('child')  
  </code></pre>
  
  <p>Here <code>children_qs</code> should now be a queryset for all Child instances used in the earlier query, instead of a queryset returning Parent instance.</p>
  
  <p>You can sort of do this with a custom queryset and an <code>__in</code> lookup but it feels a bit smelly:</p>
  
  <pre><code>class ParentQuerySet(models.QuerySet):
      ...
      def children(self):
          return Child.objects.filter(id__in=self.values_list('child_id', flat=True))
  </code></pre>
  
  <p>This takes all the <code>child_id</code> FK's from the records in the Parent's queryset and re-query Child directly. When I inspect the SQL it does a sub query, and I'm not sure if this is optimal or has some odd side effects. It does look like the ordering from the original Parent query is gone, and so are duplicates.</p>
  
  <p>Does anyone got something better then this?</p>
  
  <p>note: I'm aware I could query directly via Child and filter the Parent's fields using the reverse lookup, but that doesn't support everything you can do on the main model.</p>