summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/widgets.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index c2bc534e5a..67108e450b 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -463,7 +463,9 @@ class DateTimeBaseInput(TextInput):
self.format = format if format else None
def format_value(self, value):
- return formats.localize_input(value, self.format or formats.get_format(self.format_key)[0])
+ if value is not None:
+ # localize_input() returns str on Python 2.
+ return force_text(formats.localize_input(value, self.format or formats.get_format(self.format_key)[0]))
class DateInput(DateTimeBaseInput):