1๐
โ
I would really suggest avoiding messing with the metaclass of models as you can easily run into some weird issues that are hard to debug. Anyway, if you still want to do this, the error message tells you what you need to do.
AlphaMeta
needs to be a subclass of the metaclass of models.Model
, which is django.db.models.base.ModelBase
. So try
from django.db.models.base import ModelBase
class AlphaMeta(ModelBase):
โฆ
You probably also want to call the superclass implementation in the case of a KeyError
.
๐คMichael Mior
Source:stackexchange.com