title: Can I lookup a related field using a Q object in the Django ORM?
body: <p>In Django, can I re-use an existing Q object on multiple models, without writing the same filters twice?</p>
  
  <p>I was thinking about something along the lines of the pseudo-Django code below, but did not find anything relevant in the documentation :</p>
  
  <pre><code>class Author(Model):
    name = TextField()
    company_name = TextField()
  
  class Book(Model):
    author = ForeignKey(Author)
  
  # Create a Q object for the Author model
  q_author = Q(company_name="Books &amp; co.")
  
  # Use it to retrieve Book objects
  qs = Book.objects.filter(author__matches=q_author)
  </code></pre>
  
  <p>If that is not possible, can I extend an existing Q object to work on a related field? Pseudo-example :</p>
  
  <pre><code># q_book == Q(author__company_name="Books &amp; co.")
  q_book = q_author.extend("author")
  
  # Use it to retrieve Book objects
  qs = Book.objects.filter(q_book)
  </code></pre>
  
  <p>The only thing I've found that comes close is using a subquery, which is a bit unwieldy :</p>
  
  <pre><code>qs = Book.objects.filter(author__in=Author.objects.filter(q_author))
  </code></pre>