How to join three tables with Django ORM? <p>My models are:</p> <pre><code>class Profiles(models.Model): first_name = models.CharField() last_name = models.CharField() email = models.CharField() class Meta: db_table = 'users' class Products(models.Model): title = models.CharField() content = models.CharField() price = models.BigIntegerField() user = models.ForeignKey(Profiles, related_name="product_owner") # user_id class Meta: db_table = 'products' class UserFollows(models.Model): profile = models.ForeignKey(Profiles, related_name='profile_following') # profile_id following = models.ForeignKey(Profiles, related_name='profile_is_following') # following_id class Meta: db_table = 'user_follows' </code></pre> <p>To get what I want, I would query it a raw sql query below:</p> <pre><code>SELECT * FROM products, users, user_follows WHERE products.user_id=users.id AND user_follows.following_id=products.user_id AND user_follows.profile_id=12345; </code></pre> <p>but I need to do it with Django ORM. I can join 'users' and 'products' tables with select_related but I have no idea how to join 'user_follows'. And I need to apply filter on a field of 'user_follows' table. Please help!</p>