Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24302 closed Bug (fixed)

DurationField form field value populated with instance.__repr__()

Reported by: Michael Angeletti Owned by: Tim Graham
Component: Database layer (models, ORM) Version: 1.8alpha1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Or,

DurationField doesn't accept input in the format of its own output

In the admin's add view for a model of mine I entered a 1 day duration in 1 0:00 format into the input for a DurationField on the model, I saved my model instance. This worked fine, and redirected me back to the admin list view, where that instance's DurationField's value was displayed as 1 day, 0:00:00 (default timedelta.__repr__). I visited the instance's change view, where the same input now also contained 1 day, 0:00:00 (default timedelta.__repr__ again). I tried saving the instance again, and received a validation error of '1 day, 0:00:00' value has an invalid format. It must be in [DD] [HH:[MM:]]ss[.uuuuuu] format. (raised in django.db.models.fields.DurationField.to_python).

Change History (5)

comment:1 by Tim Graham, 10 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:2 by Tim Graham, 10 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned

comment:3 by Tim Graham, 10 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

comment:5 by Tim Graham <timograham@…>, 10 years ago

In 9744529c1245dc675cf69fd76448aa60dc934941:

[1.8.x] Fixed #24302 -- Added DurationField.formfield()

Backport of 2d7c27d3870e57edd1b2ac46b49f0a8804753a1e from master

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