Skip to content

Commit

Permalink
Fixed #18839 - Field.__init__() now calls super().
Browse files Browse the repository at this point in the history
  • Loading branch information
Carny Cheng authored and carljm committed Mar 20, 2013
1 parent 0ff12c2 commit aaec4f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions django/forms/fields.py
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/releases/1.6.txt
Expand Up @@ -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
=====================================

Expand Down
14 changes: 14 additions & 0 deletions tests/forms_tests/tests/fields.py
Expand Up @@ -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):
Expand Down

0 comments on commit aaec4f2

Please sign in to comment.