from flask_admin.contrib.sqla import ModelView from app import app, db, models admin = Admin(app, name='flask_admin') class UserView(ModelView): can_create = True can_edit = True can_delete = True admin.add_view(UserView(models.User, db.session))
from flask_admin import BaseView, expose class MyView(BaseView): @expose('/') def index(self): return self.render('myview.html') admin.add_view(MyView(name='MyView', endpoint='myview'))
from flask_admin import Admin from flask_admin.contrib.sqla import ModelView from app import app, db, models admin = Admin(app, name='flask_admin', template_mode='bootstrap3') class UserView(ModelView): can_create = True can_edit = True can_delete = True admin.add_view(UserView(models.User, db.session))This example demonstrates how to configure Flask-Admin to use the Bootstrap template. The `template_mode` property is set to 'bootstrap3' to enable this feature. In conclusion, Flask-Admin is a powerful package library that makes it easy to create administrative interfaces for Flask applications. It provides a wide range of features and customization options, making it suitable for almost any type of application.