I want all the rows of my (MovieMaster table) for which (SetMovie table) exists. These are my models
class MovieMaster(models.Model):
m_name = models.CharField('Movie Name',max_length=50)
m_desc = models.CharField('Movie Description', max_length=50)
m_image = models.ImageField('Movie Image',upload_to="pics/")
def get_absolute_url(self):
return reverse("admin_side:addmovie")
def __str__(self):
return self.m_name
class SetMovie(models.Model):
active = models.ForeignKey(MovieMaster, on_delete=models.CASCADE)
show = models.CharField('Show Time', max_length=50)
start_time = models.DateField()
end_time = models.DateField()
def get_absolute_url(self):
return reverse("admin_side:setmovie")
Basically I want to execute this sql query (SELECT * from MovieMaster INNER JOIN SetMovie ON MovieMaster.id = SetMovie.id). I am new at this. I am able to get all SetMovie row for MovieMaster by using
models.SetMovie.objects.select_related('active')
But I am not able to get all values of MovieMaster table for SetMovie table.
question from:https://stackoverflow.com/questions/65884823/django-reverse-orm-join-queries