赞
踩
在column中使用Enum:
- class User(Base):
- __tablename__ = 'user'
-
- USER_ROLE_CHOICES = ['SU', 'GA', 'CU']
-
- id = Column(Integer, primary_key=True)
- password = Column(String(128))
- last_login = Column(DateTime)
- is_superuser = Column(Boolean)
- username = Column(String(30), unique=True)
- first_name = Column(String(30))
- last_name = Column(String(30))
- email = Column(String(30))
- is_staff = Column(Boolean)
- is_active = Column(Boolean)
- date_joined = Column(DateTime)
- role = Column(Enum(USER_ROLE_CHOICES)) #AttributeError: 'list' object has no attribute 'replace'
- group = relationship('UserGroup',
- secondary=user_usergroup,
- backref='user')
role = Column(Enum('SU', 'GA', 'CU'))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。