Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.6.x] Ensured that BoundField.as_widget always returns properly loc…

…alized fields.

This is a follow-up to #18777 which improperly converted to strings in
prepare_value and as such caused regressions like #21074.

Refs #18777, #21074

Backport of 56743cf from master.
  • Loading branch information...
commit ece8d6521771635fb5e15d1093524b4f848608fa 1 parent e94efee
Florian Apolloner apollo13 authored
Showing with 3 additions and 3 deletions.
  1. +0 −3  django/forms/fields.py
  2. +3 −0  django/forms/forms.py
3  django/forms/fields.py
View
@@ -115,8 +115,6 @@ def __init__(self, required=True, widget=None, label=None, initial=None,
super(Field, self).__init__()
def prepare_value(self, value):
- if self.widget.is_localized:
- value = formats.localize_input(value)
return value
def to_python(self, value):
@@ -459,7 +457,6 @@ class DateTimeField(BaseTemporalField):
}
def prepare_value(self, value):
- value = super(DateTimeField, self).prepare_value(value)
if isinstance(value, datetime.datetime):
value = to_current_timezone(value)
return value
3  django/forms/forms.py
View
@@ -457,6 +457,9 @@ def as_widget(self, widget=None, attrs=None, only_initial=False):
if not widget:
widget = self.field.widget
+ if self.field.localize:
+ widget.is_localized = True
+
attrs = attrs or {}
auto_id = self.auto_id
if auto_id and 'id' not in attrs and 'id' not in widget.attrs:
Please sign in to comment.
Something went wrong with that request. Please try again.