diff --git a/django/forms/fields.py b/django/forms/fields.py
index b9a3d4d..63ed153 100644
a
|
b
|
class CharField(Field):
|
231 | 231 | |
232 | 232 | |
233 | 233 | class IntegerField(Field): |
| 234 | widget = NumberInput |
234 | 235 | default_error_messages = { |
235 | 236 | 'invalid': _('Enter a whole number.'), |
236 | 237 | } |
237 | 238 | |
238 | 239 | def __init__(self, max_value=None, min_value=None, *args, **kwargs): |
239 | 240 | self.max_value, self.min_value = max_value, min_value |
240 | | kwargs.setdefault('widget', NumberInput if not kwargs.get('localize') else self.widget) |
| 241 | if kwargs.get('localize') and self.widget == NumberInput: |
| 242 | # Localized number input is not well supported on most browsers |
| 243 | kwargs.setdefault('widget', super(IntegerField, self).widget) |
241 | 244 | super(IntegerField, self).__init__(*args, **kwargs) |
242 | 245 | |
243 | 246 | if max_value is not None: |
diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py
index 5a42e4b..454a834 100644
a
|
b
|
class FieldsTests(SimpleTestCase):
|
239 | 239 | f1 = IntegerField(localize=True) |
240 | 240 | self.assertWidgetRendersTo(f1, '<input id="id_f" name="f" type="text" />') |
241 | 241 | |
| 242 | def test_integerfield_subclass(self): |
| 243 | """ |
| 244 | Test that class-defined widget is not overwritten by __init__ (#22245). |
| 245 | """ |
| 246 | class MyIntegerField(IntegerField): |
| 247 | widget = Textarea |
| 248 | |
| 249 | f = MyIntegerField() |
| 250 | self.assertEqual(f.widget.__class__, Textarea) |
| 251 | f = MyIntegerField(localize=True) |
| 252 | self.assertEqual(f.widget.__class__, Textarea) |
| 253 | |
242 | 254 | # FloatField ################################################################## |
243 | 255 | |
244 | 256 | def test_floatfield_1(self): |