我使用两个 Django 包 - django-mptt(用于实现修改后的先序树遍历的工具)和 django-hvad(模型翻译)。
我有一个模型类 MenuItem,我想让它扩展 TranslatableModel 和 MPTTModel,就像这样:
class MenuItem(TranslatableModel, MPTTModel):
但它会导致元类冲突:
(TypeError: Error when calling the metaclass bases
metaclass conflict: the metaclass of a derived class
must be a (non-strict) subclass of the metaclasses of all its bases)
这个问题的解决方案是什么?我希望可以使用双重继承。