我有一个带有自定义类型ChoiceType的SQLAlchemy模型,它来自sqlalchemy_utils库。
class Recipient(Base, BaseMixin):
first_name = Column(String())
last_name = Column(String())
social_network = Column(ChoiceType(SOCIAL_NETWOKRS))其中SOCIAL_NETWOKRS是SOCIAL_NETWOKRS = [ ('vk', 'Vkontakte'), ('fb', 'Facebook'), ('youtube', 'Youtube'), ]
当我进入管理面板编辑我的模型时,我得到了下一个错误:
NotImplementedError: Not able to derive a colander type from sqlalchemy type: ChoiceType(length=255) Please explicitly provide a colander `typ` for the "social_network" Column.
如何绕过保存自动生成管理面板的限制?
发布于 2017-01-31 21:20:56
我不再使用sqlalchemy_utils,而是添加了来自漏斗的直接验证。
下一个代码片段如预期的那样工作:
class Account(BaseMixin, Base):
social_network = Column(String(), info={'colanderalchemy': {
'typ': colander.String(),
'widget': deform.widget.SelectWidget(values=SOCIAL_NETWOKRS),
}})https://stackoverflow.com/questions/41957935
复制相似问题