Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit aaec4f2bd8a63b3dceebad7804c5897e7874833d 1 parent 0ff12c2
Carny Cheng authored carljm committed
1  django/forms/fields.py
View
@@ -120,6 +120,7 @@ def __init__(self, required=True, widget=None, label=None, initial=None,
self.error_messages = messages
self.validators = self.default_validators + validators
+ super(Field, self).__init__()
def prepare_value(self, value):
return value
4 docs/releases/1.6.txt
View
@@ -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
=====================================
14 tests/forms_tests/tests/fields.py
View
@@ -63,6 +63,20 @@ def test_field_sets_widget_is_required(self):
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):
Please sign in to comment.
Something went wrong with that request. Please try again.