Django is a good framework, but some things it just gets wrong.
Let me explain.
Django does not have STI, they claim this is because STI is a bad idea. Ok, fair enough, they have stated their position, and given an alternative.
MTI.
Right, so, lets look at this.
When you request a set of objects that are supported by MTI,
what do you get?
A heterogenious list of objects each having the right class?
No, you get a homogeneous list of objects which all have the BASE CLASS.
They say, that is because you are saying that you are defining that all these objects satisfy the contract that the definition of the base class defines. BUT, the issue is that if you call a method
of one of these objects IT IS THE BASE CLASS! Irrespective of whether the subclass overrides one of these contracted methods or not. Thats not requiring satisfaction of a contract, thats BREAKING OO.
You CAN make an amended Manager class which will automatically find the correct subclass and return that instead.
Oh, wait, if you do, all sorts of things stop working. Because the
system expects managers to return base classes and if they don’t
they start failing. Not failing with an error mind you, just spinning their wheels in infinite loops as they attempt to resolve objects back to base classes.
So, instead, you have to remember to litter your code with explicit casting. Yes, you can make your casting relatively painless by creating a ‘resolve()’ method that will hunt through the subclasses looking for the right one, but come on! we all know this will end in tears.
So, MTI, nice try, but epic EPIC fail.
Sometimes, getting something pure 99% right is worse than getting something simpler but impure 100% right.