Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Ensured that BoundField.as_widget always returns properly localized f…

…ields.

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
  • Loading branch information...
commit 56743cf9e337826e4c615909570bb057142a6a7b 1 parent 9e45091
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):
@@ -468,7 +466,6 @@ class DateTimeField(BaseTemporalField):
468 466
     }
469 467
 
470 468
     def prepare_value(self, value):
471  
-        value = super(DateTimeField, self).prepare_value(value)
472 469
         if isinstance(value, datetime.datetime):
473 470
             value = to_current_timezone(value)
474 471
         return value
3  django/forms/forms.py
@@ -463,6 +463,9 @@ def as_widget(self, widget=None, attrs=None, only_initial=False):
463 463
         if not widget:
464 464
             widget = self.field.widget
465 465
 
  466
+        if self.field.localize:
  467
+            widget.is_localized = True
  468
+
466 469
         attrs = attrs or {}
467 470
         auto_id = self.auto_id
468 471
         if auto_id and 'id' not in attrs and 'id' not in widget.attrs:

0 notes on commit 56743cf

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