-
|
Here, my use case: Those classes are part of a legacy project, and I can't change them to PolymorphicModel (too many possible side effects). But now, I need to extend the project, by inheriting more classes from the base class. And I want to use django-polymorphic. So, my point: why don't I create a new base class, inherit that class from the original BaseClassWithLotsOfStuff (to allow using the goodies it contains), make it polymorphic and inherit the rest from it? So I tried that. And when running makemigrations, I got this error AssertionError: PolymorphicModel: "InheritedClassTwo._default_manager" manager is of type "Manager", but must be a subclass of PolymorphicManager I guess the problem is PolymorphicModel defines a custom manager, amongs other things, and it crashes because of the double inheritance in BaseNewClass. So, does my point make sense? Can it be done in a different way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
This will work but the PolymorphicModel must come before the base class in the inheritance MRO: class NewBaseClass(PolymorphicModel, BaseClassWithLotsOfStuff):
# New stuff here
# ... |
Beta Was this translation helpful? Give feedback.
This will work but the PolymorphicModel must come before the base class in the inheritance MRO: