django-timedelta-field / timedelta /

The branch 'py3k' does not exist.
Diff from to

File timedelta/

 from django.db import models
+from django.core.exceptions import ValidationError
 from collections import defaultdict
 import datetime
     description = "A datetime.timedelta object"
+    def __init__(self, *args, **kwargs):
+        self._min_value = kwargs.pop('min_value', None)
+        self._max_value = kwargs.pop('max_value', None)
+        super(TimedeltaField, self).__init__(*args, **kwargs)
     def to_python(self, value):
         if (value is None) or isinstance(value, datetime.timedelta):
             return value
         return super(TimedeltaField, self).formfield(*args, **defaults)
+    def validate(self, value, model_instance):
+        super(TimedeltaField, self).validate(value, model_instance)
+        if self._min_value is not None:
+            if self._min_value > value:
+                raise ValidationError('Less than minimum allowed value')
+        if self._max_value is not None:
+            if self._max_value < value:
+                raise ValidationError('More than maximum allowed value')
     def value_to_string(self, obj):
         value = self._get_val_from_obj(obj)
         return unicode(value)