Fixed #18839 - Field.__init__() now calls super().

This commit is contained in:
Carny Cheng 2013-03-18 14:22:26 -07:00 committed by Carl Meyer
parent 0ff12c28d0
commit aaec4f2bd8
3 changed files with 19 additions and 0 deletions

View File

@ -120,6 +120,7 @@ class Field(object):
self.error_messages = messages
self.validators = self.default_validators + validators
super(Field, self).__init__()
def prepare_value(self, value):
return value

View File

@ -163,6 +163,10 @@ Minor features
* The :djadmin:`diffsettings` comand gained a ``--all`` option.
* :func:`django.forms.fields.Field.__init__` now calls ``super()``, allowing
field mixins to implement ``__init__()`` methods that will reliably be
called.
Backwards incompatible changes in 1.6
=====================================

View File

@ -63,6 +63,20 @@ class FieldsTests(SimpleTestCase):
self.assertTrue(Field(required=True).widget.is_required)
self.assertFalse(Field(required=False).widget.is_required)
def test_cooperative_multiple_inheritance(self):
class A(object):
def __init__(self):
self.class_a_var = True
super(A, self).__init__()
class ComplexField(Field, A):
def __init__(self):
super(ComplexField, self).__init__()
f = ComplexField()
self.assertTrue(f.class_a_var)
# CharField ###################################################################
def test_charfield_1(self):