Questions tagged «marshmallow»

2
如果MySQL ENUM值的名称中有空格,如何定义Python Enum属性?
我有这样的Python Enum类: from enum import Enum class Seniority(Enum): Intern = "Intern" Junior_Engineer = "Junior Engineer" Medior_Engineer = "Medior Engineer" Senior_Engineer = "Senior Engineer" 在MYSQL数据库中,资历ENUM列的值为“实习生”,“初级工程师”,“中级工程师”,“高级工程师”。 问题是我得到一个错误: LookupError: "Junior Engineer" is not among the defined enum values 当我像这样调用查询时,发生了此错误: UserProperty.query.filter_by(full_name='John Doe').first() seniority是UserProperty模型中的枚举属性。 class UserProperty(db.Model): ... seniority = db.Column(db.Enum(Seniority), nullable=True) ... 对于这个类,我用定义的架构类marshmallow Schema和EnumField从marshmallow_enum包: class …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.