Readonly text field in Flask-Admin ModelView

前端 未结 5 1287
南旧
南旧 2020-12-18 23:23

How can I make a field on a ModelView readonly?

class MyModelView(BaseModelView):
    column_list = (\'name\', \'last_name\', \'email\')
         


        
5条回答
  •  青春惊慌失措
    2020-12-19 00:03

    If you're talking about Flask-Admin with SQLAlchemy Models, and you're declaring a view by inheriting from sqlamodel.ModelView, you can just add this to your class definition:

    class MyModelView(BaseModelView):
        column_list = ('name', 'last_name', 'email')
        form_widget_args = {
            'email':{
                'disabled':True
            }
        }
    

提交回复
热议问题