I am storing an object in my DB with a timefield like so:
class MyClass(models.Model):
start_time = models.TimeField(null=True, blank=True)
stop_time = models.TimeField(null=True, blank=True)
The idea here is that when querying an endpoint, the server will return only objects where the current time is between the start_time and stop_time.
NB: start_time and stop_time are arbitrary times of the day, and can span across midnight, but will never be more than 24hr apart.
I have tried
currentTime = datetime.now().time()
MyClass.objects.filter(stop_time__gte=currentTime, start_time__lte=currentTime)
but this does not account for when the times span midnight.
I'm sure there must be a simple solution to this, but web search has left me fruitless. Does anyone know a good way to do this?