Search code examples
pythonflaskflask-sqlalchemyflask-admin

How to exclude column from create, but validate in edit in flask-admin?


To remove fields from the create and edit forms:

form_excluded_columns = ['last_name', 'email']

I want to label edited rows with comments. For example we create row with columns: name, count, payment. After we edit payment column, we MUST append comment about why we change this.

How to apply such behavior in flask-admin?

Thanks


Solution

  • form_create_rules = [rules.FieldSet('name', 'count', 'payment')]
    form_edit_rules = [rules.FieldSet('comment')]
    form_args = dict(comment=dict(validators=[required()]))
    

    Solve my problem, but I can't reject the feeling, I'm doing something wrong.