来自FlaskMongoKi的元类错误

2024-09-29 02:28:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Flask、Flask login和Flask MongoKit组装一个基本的登录系统。你知道吗

这是我的User课程:

class User(Document):
    __collection__ = 'users'
    structure = {
        'username': basestring,
        'password': basestring,
        'date_created': datetime
    }
    required_fields = ['username', 'password']
    default_values = {
        'date_created': datetime.utcnow
    }

当我将文档模型连接到数据库(db.register([User]))时,对文档(db.User.one({'username': form.username}))进行查询会产生以下可爱的错误:

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

我完全不明白这个错误,我也不知道该怎么纠正它。怎么了?你知道吗

注意:我理解什么是元类冲突。我不知道我是怎么造成的:它似乎是在MongoKit内部的某个地方触发的。你知道吗


Tags: of文档flaskdbdatetimedate错误username