title: Django query users that like each other
body: <p>I have a Django model that looks like this:</p>
  
  <pre><code>class Matches(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      voter = models.ForeignKey(User, related_name='given_vote', on_delete=models.CASCADE)
      vote = models.BooleanField(default=False)
  </code></pre>
  
  <p>I am trying to write a query using django's ORM, but am stuck. Given a user (let's say user_1), I want to return all rows where user_1 has voted True on another user (let's say user_2) AND user_2 has voted True on user_1.</p>
  
  <p>I'm thinking I might need to use Django's Q <a href="https://docs.djangoproject.com/en/2.2/topics/db/queries/#complex-lookups-with-q-objects" rel="nofollow noreferrer">function</a> but not sure. Here is what I've got: </p>
  
  <pre><code>class User:
      def calculate_matches(self):    
          return Matches.objects.filter(Q(voter=self, vote=True) &amp; Q(user=self, vote=True))
  </code></pre>