I have a template tag that returns a list of shows:
def get_all_shows():
allshows = Shows.objects.all().order_by("-broadcast_day", "-broadcast_time")[:9].reverse()
tags = Shows.tags.all()
return {'allshows': allshows, 'tags': tags}
In my models have a day choice field:
class Shows(models.Model):
CHOICES = (
('Monday', 'Monday'),
('Tuesday', 'Tuesday'),
('Wednesday', 'Wednesday'),
('Thursday', 'Thursday'),
('Friday', 'Friday'),
('Saturday', 'Saturday'),
('Sunday', 'Sunday'),
)
broadcast_day = models.CharField(default=1,max_length=12, choices=CHOICES, blank=True)
broadcast_time = models.TimeField(default=datetime.now, blank=True)
My question is how do I order my list by day so the nearest day will show the corresponding show?
And also is it possible to calculate the date on that day?
Thanks.