mirror of https://github.com/django/django.git
[1.6.x] Ensured that BoundField.as_widget always returns properly localized 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 56743cf9e3
from master.
This commit is contained in:
parent
e94efee946
commit
ece8d65217
|
@ -115,8 +115,6 @@ class Field(object):
|
||||||
super(Field, self).__init__()
|
super(Field, self).__init__()
|
||||||
|
|
||||||
def prepare_value(self, value):
|
def prepare_value(self, value):
|
||||||
if self.widget.is_localized:
|
|
||||||
value = formats.localize_input(value)
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
|
@ -459,7 +457,6 @@ class DateTimeField(BaseTemporalField):
|
||||||
}
|
}
|
||||||
|
|
||||||
def prepare_value(self, value):
|
def prepare_value(self, value):
|
||||||
value = super(DateTimeField, self).prepare_value(value)
|
|
||||||
if isinstance(value, datetime.datetime):
|
if isinstance(value, datetime.datetime):
|
||||||
value = to_current_timezone(value)
|
value = to_current_timezone(value)
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -457,6 +457,9 @@ class BoundField(object):
|
||||||
if not widget:
|
if not widget:
|
||||||
widget = self.field.widget
|
widget = self.field.widget
|
||||||
|
|
||||||
|
if self.field.localize:
|
||||||
|
widget.is_localized = True
|
||||||
|
|
||||||
attrs = attrs or {}
|
attrs = attrs or {}
|
||||||
auto_id = self.auto_id
|
auto_id = self.auto_id
|
||||||
if auto_id and 'id' not in attrs and 'id' not in widget.attrs:
|
if auto_id and 'id' not in attrs and 'id' not in widget.attrs:
|
||||||
|
|
Loading…
Reference in New Issue