A python/django beginner's question:
I have a datetime object (drive_date), a time object (start_time) and a timedelta object (when_to_notify).
I first do this:
d = datetime.combine(l.drive_date, l.start_time)
I would then like to subtract the "when_to_notify" timedelta object from d to get a notification date and time. However, django doesn't like this. It tells me: TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.timedelta'
How can I subtract the time in the timedelta object from a datetime object?
[moved from comment section]
datetime.combine
returns a datetime
from which a datetime.timedelta
can be subtracted. From the exception it seems you are trying to subtract a datetime.timedelta
from a time object instead of a datetime
object. Can you recheck?