📅  最后修改于: 2022-03-11 14:45:53.070000             🧑  作者: Mango
class MyModel(db.Model):
id = db.Column(db.Integer, primary_key=True)
my_field = db.Column(db.String(128)) # Field I would like to be choices
class MyModelView(ModelView):
"""
Admin manager for MyModel
"""
form_choices = {
'my_field': [
('choice_1', 'Choice 1'),
('choice_2', 'Choice 2'),
('choice_3', 'Choice 3'),
('choice_4', 'Choice 4'),
('choice_5', 'Choice 5')
]
}
def __init__(self):
super(MyModelView, self).__init__(MyModel, db.session)