I want to know about the best way to find the difference between two time objects in Django. I want to know whether the time of a particular object is in a difference of 4 hours or not.
I have my models.py as
class Task(models.Model):
time = models.TimeField()
In the shell, I tried something like
from django.utils.timzone import datetime, timedelta
obj_time = Task.objects.first().time
obj_time - datetime.now().time() < timedelta(hours=4)
But I get the following error
TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.time'
How should I go about solving this?