Difficulty using the new DurationField in Django 1.8
I'm having a bit of trouble with Django's new DurationField for models.
I want the user to be able to choose if the duration of an event on my webapp is 1 day, 3 days, or 5 days, with the default choice being 3 days.
At the beginning of my model, I declare the choices:
SHORT = datetime.timedelta(days=1)
MEDIUM = datetime.timedelta(days=3)
LONG = datetime.timedelta(days=5)
DURATION_CHOICES = ((SHORT, '1 day'),(MEDIUM, '3 days'), (LONG, '5 days'),)
Then below, I declare the DurationField:
duration = models.DurationField(choices = DURATION_CHOICES, default = MEDIUM)
I created a ModelForm for the model, and rendered it on the appropriate template. On the form, "3 days" was the preselected choice in the dropdown, and "1 day" and "5 days" are options as well. However, when I submit the form, I get the form validation error "Select a valid choice. 3 days, 0:00:00 is not one of the available choices."
However, when I remove the choices from DurationField and leave the default:
duration = models.DurationField(default = MEDIUM)
I can submit without any issues. What am I doing wrong here?