This question is different from: Using __new__ in classes derived from Django models does not work
This question asks how __new__ work can be done.
This question asks : What are the pitfalls of using __new__ with Django models?
In particular, I have the following code that exists to set the class of a class in a class that needs to know which class it belongs to (i.e., it needs to indicate whether it will be called in the subclass or not). Will it explode in unexpected ways?
class Director(models.Model, Specializable, DateFormatter, AdminURL, Supercedable):
For completeness, create_subclass_translator does something like this:
@classmethod def create_subclass_translator(clazz, Baseclass, install=None): def create_from_other_instance(selfclass, old_instance, properties): if selfclass is Baseclass: raise TypeError("This method cannot be used on the base class")
For those who are wondering what this does, classmethod create_from_other_instance is a factory that mimics an instance of a subclass of a model that changes from one subclass to another by copying over the properties of the base class and setting the ancestor_link property correctly.
source share