From e13dca859cec90b7a04d51117fec5c18c6f90a9f Mon Sep 17 00:00:00 2001 From: Michael Angeletti Date: Sat, 14 Feb 2015 16:33:09 -0500 Subject: [PATCH] [1.8.x] Added missing return value to DurationField.prepare_value(); refs #24339. Backport of 49647bec6e86b8d3d370ea1d8a80423185502c5a from master --- django/forms/fields.py | 1 + tests/forms_tests/tests/test_fields.py | 1 + 2 files changed, 2 insertions(+) diff --git a/django/forms/fields.py b/django/forms/fields.py index 49b31ccc59..ebc25610ee 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -528,6 +528,7 @@ class DurationField(Field): def prepare_value(self, value): if isinstance(value, datetime.timedelta): return duration_string(value) + return value def to_python(self, value): if value in self.empty_values: diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py index 1d1f8febda..5bbf640463 100644 --- a/tests/forms_tests/tests/test_fields.py +++ b/tests/forms_tests/tests/test_fields.py @@ -640,6 +640,7 @@ class FieldsTests(SimpleTestCase): field = DurationField() td = datetime.timedelta(minutes=15, seconds=30) self.assertEqual(field.prepare_value(td), duration_string(td)) + self.assertEqual(field.prepare_value('arbitrary'), 'arbitrary') self.assertIsNone(field.prepare_value(None)) # RegexField ##################################################################