#24339 closed Bug (fixed)
Exception at /add admin view when using DurationField
| Reported by: | Michael Angeletti | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | 1.8alpha1 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
Setup
Make an app with a model that has a DurationField. (started fresh app to verify)
Exception
AttributeError: 'NoneType' object has no attribute 'days' was the error message.
Cause
https://github.com/django/django/blob/0ed7d155635da9f79d4dd67e4889087d3673c6da/django/forms/fields.py#L517 (assumes value is a timedelta)
Solution
def prepare_value(self, value):
if isinstance(value, datetime.timedelta):
return duration_string(value)
return value
Change History (7)
comment:1 by , 11 years ago
| Component: | Uncategorized → Forms |
|---|
comment:2 by , 11 years ago
| Has patch: | set |
|---|
comment:3 by , 11 years ago
| Triage Stage: | Unreviewed → Ready for checkin |
|---|---|
| Type: | Uncategorized → Bug |
comment:4 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
PR