Why this code doesn’t work?
I see in debugger (PyCharm) that init line is executed but nothing more.
I have tried to put there raise exception to be really sure and again nothing happend.
class polo(object):
def __init__(self):
super(polo, self).__init__()
self.po=1 <- this code is newer executed
class EprForm(forms.ModelForm, polo):
class Meta:
model = models.Epr
You use multiple inheritance so in general Python will look for methods in left-to-right order. So if your class do not have
__init__it’ll look for it inModelFormand that (only if not found) inpolo. In your code thepolo.__init__is never called becauseModelForm.__init__is called.To call the constructors of both base classes use explicit constructor call: