Skip to content

Commit

Permalink
[1.6.x] Ensured that BoundField.as_widget always returns properly loc…
Browse files Browse the repository at this point in the history
…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
apollo13 committed Sep 21, 2013
1 parent e94efee commit ece8d65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions django/forms/fields.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions django/forms/forms.py
Expand Up @@ -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:
Expand Down

0 comments on commit ece8d65

Please sign in to comment.