summaryrefslogtreecommitdiff
path: root/django/forms/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms/widgets.py')
-rw-r--r--django/forms/widgets.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 76c12e2dcb..0f861f0046 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -1004,7 +1004,10 @@ class SelectDateWidget(Widget):
if isinstance(value, (datetime.date, datetime.datetime)):
year, month, day = value.year, value.month, value.day
elif isinstance(value, str):
- if settings.USE_L10N:
+ match = self.date_re.match(value)
+ if match:
+ year, month, day = [int(val) for val in match.groups()]
+ elif settings.USE_L10N:
input_format = get_format('DATE_INPUT_FORMATS')[0]
try:
d = datetime.datetime.strptime(value, input_format)
@@ -1012,9 +1015,6 @@ class SelectDateWidget(Widget):
pass
else:
year, month, day = d.year, d.month, d.day
- match = self.date_re.match(value)
- if match:
- year, month, day = [int(val) for val in match.groups()]
return {'year': year, 'month': month, 'day': day}
@staticmethod