Odejmij 2 obiekty datetime django
# You can just subtract the dates directly, which will yield a datetime.timedelta object:
dt = weight_now.weight_date - weight_then.weight_date
# A timedelta object has fields for days, seconds, and microseconds.
# From there, you can just do the appropriate math. For example:
hours = dt.seconds / 60 / 60 # Returns number of hours between dates
weeks = dt.days / 7
Jittery Jay