Opened 3 years ago

Closed 3 years ago

#32249 closed Bug (duplicate)

Increment of duration field not works properly

Reported by: Alex Zaitsev Owned by: nobody
Component: Database layer (models, ORM) Version: 3.1
Severity: Normal Keywords: duration
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a duration field in some model:

My(models.Model):
   ...
   duration = models.DurationField(default=timedelta(seconds=0))

and I try to increment durations via F expression:

obj.duration = F('duration') + (now - some_other_datetime)

as a result, we have a value of the following format in the database: 0:18:30.233251 instead of a big integer one. So this makes that instance of model completely unusable, any attempt of access raise an exception: TypeError: unsupported type for timedelta microseconds component: str

Change History (1)

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: duplicate
Status: newclosed
Type: UncategorizedBug

Duplicate of #28925, fixed in dd5aa8cb5ffc0a89c4b9b8dee45c1c919d203489 (Django 3.2+).

Note: See TracTickets for help on using tickets.
Back to Top