'children', ] column_filters = [ 'id', 'name', 'parent', ] # override the 'render' method to pass your own parameters to the template def render(self, template, **kwargs): return super(TreeView, self).render(template, foo="bar", **kwargs) # Create admin admin = admin.Admin(app, name='Example: SQLAlchemy', template_mode='bootstrap4') # Add views admin.add_view(UserAdmin(User, db.session)) admin.add_view(sqla.ModelView(Tag, db.session)) # The "Post" model gets added in the overriddent __init__(self, Post, session) admin.add_view(PostAdmin(db.session)) admin.add_view(TreeView(Tree, db.session, category="Other")) admin.add_sub_category(name="Links", parent_name="Other") admin.add_link(MenuLink(name='Back Home', url='/', category='Links')) admin.add_link( MenuLink(name='External link', url='http://www.example.com/', category='Links'))
# Flask-admin can automatically detect the relevant filters for hybrid properties. column_filters = ('number_of_pixels', ) # Create admin admin = admin.Admin(app, name='Example: SQLAlchemy', template_mode='bootstrap3') # Add views admin.add_view(UserAdmin(User, db.session)) admin.add_view(sqla.ModelView(Tag, db.session)) admin.add_view(PostAdmin(db.session)) admin.add_view(sqla.ModelView(Pet, db.session, category="Other")) admin.add_view(sqla.ModelView(UserInfo, db.session, category="Other")) admin.add_view(TreeView(Tree, db.session, category="Other")) admin.add_view(ScreenView(Screen, db.session, category="Other")) admin.add_sub_category(name="Links", parent_name="Other") admin.add_link(MenuLink(name='Back Home', url='/', category='Links')) admin.add_link(MenuLink(name='Google', url='http://www.google.com/', category='Links')) admin.add_link(MenuLink(name='Mozilla', url='http://mozilla.org/', category='Links')) def build_sample_db(): """ Populate a small db with some example entries. """ import random import datetime db.drop_all() db.create_all()