I'm trying to assemble a basic login system using Flask, Flask-Login, and Flask-MongoKit.
Here's my User
class:
class User(Document):
__collection__ = 'users'
structure = {
'username': basestring,
'password': basestring,
'date_created': datetime
}
required_fields = ['username', 'password']
default_values = {
'date_created': datetime.utcnow
}
When I connect the Document model to the database ( db.register([User])
), querying against the document ( db.User.one({'username': form.username})
) gives me this lovely error:
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
I don't understand this error at all, and I have no idea how to fix it. What's going wrong?
NOTE: I understand what a metaclass conflict is . What I don't see is how I've caused one: it seems to be triggered somewhere inside MongoKit.
原来的问题是我导入了错误的类(我将父模块提供给db.register
而不是该类。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.