I have a Motion
model which has many Votes
. I display the votes as an inline_model
in flask-admin
. Is it possible to render the votes as a table like in the list_view
template? Instead of like this:
flask-admin: Render inline_models as list view?
Asked Answered
Using using rules from flask-admin you can change the way either the create form or the edit form looks.
class View(sqla.ModelView):
form_create_rules = {
#for instance
attribute1,
rules.Header('A header'),
attribute2
}
If you want more customization you can also use formatters
class View(sqla.ModelView):
form_create_rules = {
#for instance
attribute1,
rules.Header('A header'),
attribute2
}
def _a_column_formatter(view, context, model, name):
#returns the content of a row in h3 html tags
return Markup('<h3>{}</h3>'.format(model.attribute))
column_formatters = {
'ticket_name': _a_column_formatter
}
Have a look at http://flask-admin.readthedocs.io/en/latest/api/mod_model/#flask_admin.model.BaseModelView.column_formatters
© 2022 - 2024 — McMap. All rights reserved.