model field code is this
created = models.DateTimeField(auto_now=True)
@property
def now_diff(self):
return timezone.now() - self.created
I have a question about django time circulation using virtual field
current output of time circulation is 5:26:34.349728
But I want to 5:26:34
Is there a way?
thanks for let me know ~!
i chaged to
@property
def now_diff(self):
s=timezone.now() - self.created
hours, remainder = divmod(s, 3600)
minutes, seconds = divmod(remainder, 60)
return '{:02}:{:02}:{:02}'.format(int(hours), int(minutes), int(seconds))
but error
TypeError: 'Todo' object is not subscriptable
TypeError: unsupported operand type(s) for divmod(): 'datetime.timedelta' and 'int'