Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[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 authored September 21, 2013
3  django/forms/fields.py
@@ -115,8 +115,6 @@ def __init__(self, required=True, widget=None, label=None, initial=None,
115 115
         super(Field, self).__init__()
116 116
 
117 117
     def prepare_value(self, value):
118  
-        if self.widget.is_localized:
119  
-            value = formats.localize_input(value)
120 118
         return value
121 119
 
122 120
     def to_python(self, value):
@@ -459,7 +457,6 @@ class DateTimeField(BaseTemporalField):
459 457
     }
460 458
 
461 459
     def prepare_value(self, value):
462  
-        value = super(DateTimeField, self).prepare_value(value)
463 460
         if isinstance(value, datetime.datetime):
464 461
             value = to_current_timezone(value)
465 462
         return value
3  django/forms/forms.py
@@ -457,6 +457,9 @@ def as_widget(self, widget=None, attrs=None, only_initial=False):
457 457
         if not widget:
458 458
             widget = self.field.widget
459 459
 
  460
+        if self.field.localize:
  461
+            widget.is_localized = True
  462
+
460 463
         attrs = attrs or {}
461 464
         auto_id = self.auto_id
462 465
         if auto_id and 'id' not in attrs and 'id' not in widget.attrs:

0 notes on commit ece8d65

Please sign in to comment.
Something went wrong with that request. Please try again.