How to JOIN three tables with Django ORM
from django.db import models
class Artist(models.Model):
name = models.CharField(max_length=60)
year_established = models.SmallIntegerField()
votes = models.IntegerField(blank=True, null=True)
class Song(models.Model):
artist = models.ForeignKey(Artist, related_name='songs')
title = models.CharField(max_length=5)
votes = models.IntegerField()
class Fan(models.Model):
artist = models.ForeignKey(Artist, related_name='fans')
name = models.CharField(max_length=5)
votes_casted = models.IntegerField()