Commits

Matthew Schinckel  committed 1c36489

Added a TimedeltaChoicesField

  • Participants
  • Parent commits 535436a

Comments (0)

Files changed (1)

File timedelta/forms.py

             raise forms.ValidationError(self.error_messages['invalid'])
             
         return datetime.timedelta(**data)
+
+class TimedeltaChoicesField(TimedeltaFormField):
+    def __init__(self, *args, **kwargs):
+        choices = kwargs.pop('choices')
+        defaults = {'widget':forms.Select(choices=choices)}
+        defaults.update(kwargs)
+        super(TimedeltaChoicesField, self).__init__(*args, **defaults)