I want to do an extra initalization whenever instances of a specific django model are created. I know that overriding __init__ can lead to trouble. What other alternatives should I consider?
Update. Additional details: The intent is to initialize a state-machine that the instances of that model represent. This state-machine is provided by an imported library, and it's inner state is persisted by my django-model. The idea is that whenever the model is loaded, the state machine would be automatically initialized with the model's data.
__init__
doesn't work, the OP just did it all wrong. You're free to override__init__
, but the efficacy of that is entirely dependent on what exactly you're trying to do. So why don't you tell us that, so we can actually help you.(self, *args, **kwargs)
, overriding __init__ won't get on django's way?