Skip to content
Advertisement

How to call super of enclosing class in a mixin in Python?

I have the following code, in Django:

JavaScript

Now, I want to use the mixin without blatting the behaviour of the save in Parent. So I when I save, I want to do stuff C, B, and A. I’ve read Calling the setter of a super class in a mixin however I don’t get it and having read the super docs it doesn’t seem to answer my question.

THe question is, what do I put in the mixin to make sure it does stuff B and doesn’t stop Stuff A from happening?

Advertisement

Answer

How about calling super in your mixin class?

JavaScript

This will give you the output as:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement