﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24897	Choices longer than 1 day don't work with DurationField	zauddelig	nobody	"When one tries to use DurationField with choices and a time span longer than a day the field will always raise a ValidationError.

{{{
choices = (timedelta(days=7), ""one week"")
}}}

The problem is in the `to_python` method wich calls `django.utils.dateparse.parse_duration` this methond use the following regex:
{{{
standard_duration_re = re.compile(
    r'^'
    r'(?:(?P<days>-?\d+) )?'
    r'((?:(?P<hours>\d+):)(?=\d+:\d+))?'
    r'(?:(?P<minutes>\d+):)?'
    r'(?P<seconds>\d+)'
    r'(?:\.(?P<microseconds>\d{1,6})\d{0,6})?'
    r'$'
)
}}}

But is not standard in the view that we are using timedelta objects, whose default rapresentation is : `%d days, %h:%m:%s`. So I propose to change the regex in with the following:
{{{
 standard_duration_re = re.compile(
    r'^'
    r'(?:(?P<days>-?\d+) (days, )?)?'
    r'((?:(?P<hours>\d+):)(?=\d+:\d+))?'
    r'(?:(?P<minutes>\d+):)?'
    r'(?P<seconds>\d+)'
    r'(?:\.(?P<microseconds>\d{1,6})\d{0,6})?'
    r'$'
)
}}}"	Bug	closed	Forms	1.8	Normal	fixed	DurationField		Accepted	1	0	1	0	0	0
