First of all I'm new to python and that is my first post so, please, let me know if I did something wrong around here and I'll gladly fix it.
I'm using Python 2.7.15rc1 and Peewee 3.6.4
What I'm trying to achieve is create a class that inherits from peewee's Model and also from PySide.QtCore's QObject. Just like this:
class BaseModel(Model, QObject):
id = PrimaryKeyField()
class Meta:
database = db
def __str__(self):
return str(self.__dict__)
def __eq__(self, other):
return self.id == other.id
But this configuration brings me the following error:
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
If I try to specify Model as the desired metaclass (and I think it is ok because basically I only need the "is a" relation with QObject to be true) by adding this to BaseModel:
__metaclass__ = Model
The following error is thrown:
AttributeError: 'Model' object has no attribute '_meta'
also, by following this link, I've changed code to this:
class A (Model):
pass
class B (QObject):
pass
class C(A, B):
pass
class BaseModel(A, B):
__metaclass__ = C
id = PrimaryKeyField()
class Meta:
database = db
def __str__(self):
return str(self.__dict__)
def __eq__(self, other):
return self.id == other.id
But the metaclass conflict persists.
What am I doing wrong around here?