I have a django abstract class:
class AbstractModel(models.Model):
date_added = models.DateField(auto_now_add=True)
class Meta:
abstract = True
I want my concrete classes (Django Models) to subclass this abstract class, but I also want to make sure that all my concrete classes always implement very specific methods using abc.
I tried doing this:
class AbstractBaseClass(AbstractModel, metaclass=abc.ABCMeta):
@abstractmethod
def important_method(self):
pass
class MyDjangoModel(AbstractBaseClass):
...
And I tried:
class AbstractBaseClass(ABC):
@abstractmethod
def important_method(self):
pass
class MyDjangoModel(AbstractModel, AbstractBaseClass):
Neither worked. They both say:
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Is there a way to do this, or is this impossible?