Flask-AppBuilder icon indicating copy to clipboard operation
Flask-AppBuilder copied to clipboard

How to update a defined modelview in the runtime.

Open QKJIN opened this issue 2 years ago • 1 comments

I'm implement to add a column(or field) into a table in the runtime. And I have completed the function. But there is still a problem. After adding the new column into table, I use setattr() method to add the new column to the relative model. And then this model has a new column. But I don't know how to update a defined modelview. When I list a modelview, it still lists the old columns. The new column is not updated into modelview. In the modelview class, I think datamodel(datamodel = SQLAInterface(Model)) should be updated after a new column is added. Or use appbuilder.add_view to rebuild a new modelview. But I don't know how to do.

QKJIN avatar Aug 17 '22 10:08 QKJIN

I almost complete this func. When I add a new column and re-mapping the new column to model attrs, then I need to refresh the datamodel of this related modelview. I re-init this datamodel. But when I use self.datamodel.init(model) in render_template(self, template, **kwargs), I got this "An error occurred:" . I'm stuck here for a few days and don't know how to update the datamodel. Who can help me, thank you so much.

QKJIN avatar Aug 24 '22 04:08 QKJIN