Added missing return value to DurationField.prepare_value(); refs #24339.
This commit is contained in:
parent
a73c8540a8
commit
49647bec6e
|
@ -516,6 +516,7 @@ class DurationField(Field):
|
||||||
def prepare_value(self, value):
|
def prepare_value(self, value):
|
||||||
if isinstance(value, datetime.timedelta):
|
if isinstance(value, datetime.timedelta):
|
||||||
return duration_string(value)
|
return duration_string(value)
|
||||||
|
return value
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
if value in self.empty_values:
|
if value in self.empty_values:
|
||||||
|
|
|
@ -647,6 +647,7 @@ class FieldsTests(SimpleTestCase):
|
||||||
field = DurationField()
|
field = DurationField()
|
||||||
td = datetime.timedelta(minutes=15, seconds=30)
|
td = datetime.timedelta(minutes=15, seconds=30)
|
||||||
self.assertEqual(field.prepare_value(td), duration_string(td))
|
self.assertEqual(field.prepare_value(td), duration_string(td))
|
||||||
|
self.assertEqual(field.prepare_value('arbitrary'), 'arbitrary')
|
||||||
self.assertIsNone(field.prepare_value(None))
|
self.assertIsNone(field.prepare_value(None))
|
||||||
|
|
||||||
# RegexField ##################################################################
|
# RegexField ##################################################################
|
||||||
|
|
Loading…
Reference in New Issue