title: Filter by custom QuerySet of a related model in Django
body: <p>Let's say I have two models: <code>Book</code> and <code>Author</code></p>
  
  <pre><code>class Author(models.Model):
      name = models.CharField()
      country = models.CharField()
      approved = models.BooleanField()
  
  
  class Book(models.Model):
      title = models.CharField()
      approved = models.BooleanField()
      author = models.ForeignKey(Author)
  </code></pre>
  
  <p>Each of the two models has an <code>approved</code> attribute, which shows or hides the object from the website. If the <code>Book</code> is not approved, it is hidden. If the <code>Author</code> is not approved, all his books are hidden.</p>
  
  <p>In order to define these criteria in a DRY manner, making a custom QuerySet looks like a perfect solution:</p>
  
  <pre><code>class AuthorQuerySet(models.query.QuerySet):
      def for_site():
          return self.filter(approved=True)
  
  class BookQuerySet(models.query.QuerySet):
      def for_site():
          reuturn self.filter(approved=True).filter(author__approved=True)
  </code></pre>
  
  <p>After hooking up these QuerysSets to the corresponding models, they can be queried like this: <code>Book.objects.for_site()</code>, without the need to hardcode all the filtering every time.</p>
  
  <hr>
  
  <p>Nevertheless, this solution is still not perfect. Later I can decide to add another filter to authors:</p>
  
  <pre><code>class AuthorQuerySet(models.query.QuerySet):
      def for_site():
          return self.filter(approved=True).exclude(country='Problematic Country')
  </code></pre>
  
  <p>but this new filter will only work in <code>Author.objects.for_site()</code>, but not in <code>Book.objects.for_site()</code>, since there it is hardcoded.</p>
  
  <hr>
  
  <p>So my questions is: <strong>is it possible to apply a custom queryset of a related model when filtering on a different model</strong>, so that it looks similar to this:</p>
  
  <pre><code>class BookQuerySet(models.query.QuerySet):
      def for_site():
          reuturn self.filter(approved=True).filter(author__for_site=True)
  </code></pre>
  
  <p>where <code>for_site</code> is a custom QuerySet of the <code>Author</code> model.</p>