my models.py:
class Attendancename(models.Model):
teacher_name = models.ForeignKey(Teachername, default=\'Ram\')
date = models.DateField(\'Date\', defaul
It's because you cannot subtract a datetime.time
from a datetime.time
. Convert them to datetime.datetime
objects and it'll return a datetime.timedelta
object that you could use.
If you're lucky enough to be using Django 1.8, they now have a DurationField that can be used.
Failing that, I would recommend converting the timedelta
into either seconds or a floating point representation so you can actually store it to the database.
EDIT: Pulled up in comments for half arsing an answer.
For example - if you want to store the number of (integer) seconds, you can convert from a TimeDelta
by using secs = td // timedelta(seconds=1)
.