I have a Business Hours that I need to compare and I'm getting incomplete results if the business hours are past midnight
My Model
class Hours(models.Model):
dayofweek = models.ForeignKey('Dayofweek')
opentime = models.TimeField(blank=True, null=True)
closetime = models.TimeField(blank=True, null=True)
...
If I just need to display hours everything works OK such: Saturday 5pm - 2am
Now when I'm trying to query the hours to check if the business is even open, those with past midnight hours will return False
for exists()
:
my query
if Hours.objects.filter(
business__id=id,
dayofweek__pyday=dt,
opentime__lte=mytime,
closetime__gte=mytime).exists():
#do something
Any suggestions how to tell Django that the 2am is after 5pm?