Using Flask-Appbuilder I can't work out how to do the seemingly simple task of displaying all values from all columns in a table as a ModelView ie:
col1 col2 col3
1 x y
2 p z
etc..
The canonical example on the flask-apbuilder uses hard coded column names:
class ContactModelView(ModelView):
datamodel = SQLAInterface(Contact)
label_columns = {'contact_group':'Contacts Group'}
list_columns = ['name','personal_celphone','birthday','contact_group']
show_fieldsets = [
('Summary',{'fields':['name','address','contact_group']}),
('Personal Info',{'fields':['birthday','personal_phone','personal_celphone'],'expanded':False}),
]
While a could just do a PRAGMA table_info(table_name) and feed the result back in to list_columns, I was hoping there may be an alternate way to doing this?
I decided to just use JQuery DataTables with Ajax to get around this. There is a good tutorial for simple table display here:
https://sarahleejane.github.io/learning/python/2015/08/09/simple-tables-in-webapps-using-flask-and-pandas-with-python.html