#17161: Call super in BaseForm.__init__
-------------------------------+--------------------
Reporter: reames@… | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.3
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Currently /django/forms/forms.py !BaseForm.!__init!__ (as well as a fair
number of other classes) does not call super().!__init!__. This makes it
impossible to create form mixins.
Consider:
{{{
from django import forms
class FormMixin(object):
def __init__(self, *args, **kwargs):
super(FormMixin, self).__init__(*args, **kwargs)
self.my_flag = true
class MyForm(forms.Form, FormMixin):
field1 = forms.CharField()
class MyModelForm(forms.ModelForm, FormMixin):
class Meta(object):
model = SpamModel
}}}
Because of python's mro the init() in the mixin never gets called because
!BaseForm.!__init!__ does not call it.
Ideally, all classes in django that have an !__init!__() should also call
super().!__init!__()
--
Ticket URL: <https://code.djangoproject.com/ticket/17161>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.