【发布时间】:2020-04-29 09:09:48
【问题描述】:
我已经成功地覆盖了烧瓶中的on_model_change,但是当我尝试对after_model_change 做同样的事情时,它什么也没做,如何在模型更改后对模型进行更改?
Class CustomAdminView(ModelView): # pylint: disable=no-init
#works fine and udpates the column
def on_model_change(self, form, model, is_created):
curr_user = getpass.getuser()
model.updatedby = curr_user
#does nothing to the model
def after_model_change(self, form, model, is_created):
current_remarks= model.remarks
model.rhistory = f'changes made : {current_remarks}'
我正在做的是获取当前备注并将其更新到历史记录,但是我只能在将备注列数据更新到模型后才能获取 如果在模型更新后无法进行更改,我可以获取用户输入的备注的值,以便在模型更新期间进行更新。
【问题讨论】:
标签: python flask flask-admin