1
You can achieve this by making use of ManyToManyField
.
Only two steps is needed:
- Create a
ManyToManyField
fieldsmovieActiveDays
forTheaterShowTimings
. - Make query with the new
movieActiveDays
field.
Model definition
class TheaterShowTimings(models.Model):
showname = models.CharField(max_length=100)
showtime = models.TimeField() # stores only time
theatershowtimingsid = models.CharField(primary_key=True, max_length=100)
# many to many fields to MovieActiveDays
movieActiveDays = models.ManyToManyField('MovieActiveDays', through='ActiveShowTimings')
def __str__(self):
return self.theatershowtimingsid
Query:
TheaterShowTimings.objects.filter(movieActiveDays__date='2016-12-19').distinct()
Source:stackexchange.com