From aaec4f2bd8a63b3dceebad7804c5897e7874833d Mon Sep 17 00:00:00 2001 From: Carny Cheng Date: Mon, 18 Mar 2013 14:22:26 -0700 Subject: [PATCH] Fixed #18839 - Field.__init__() now calls super(). --- django/forms/fields.py | 1 + docs/releases/1.6.txt | 4 ++++ tests/forms_tests/tests/fields.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/django/forms/fields.py b/django/forms/fields.py index e708ef846e..ecad857f72 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -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 diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt index 3e6c3b8bfb..132ce68232 100644 --- a/docs/releases/1.6.txt +++ b/docs/releases/1.6.txt @@ -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 ===================================== diff --git a/tests/forms_tests/tests/fields.py b/tests/forms_tests/tests/fields.py index 95e14c4434..7516de29b4 100644 --- a/tests/forms_tests/tests/fields.py +++ b/tests/forms_tests/tests/fields.py @@ -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):