-
-
Notifications
You must be signed in to change notification settings - Fork 303
Description
Here, my use case:
from django.db import models
from polymorphic.models import PolymorphicModel
class BaseClassWithLotsOfStuff(models.Model):
# Here, a lot of existing atributes (variables and methods)
# ...
class InheritedClassOne(BaseClassWithLotsOfStuff):
# A lot of stuff here too...
#...
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?
class NewBaseClass(BaseClassWithLotsOfStuff, PolymorphicModel):
# New stuff here
# ...
class InheritedClassTwo(NewBaseClass):
# We are polymorphic now!
# ...
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?