Base View

expose(url='/', methods=('GET', ))[source]

Use this decorator to expose views in your view classes.

  • url – Relative URL for the view
  • methods – Allowed HTTP methods. By default only GET is allowed.

Decorator to expose Flask’s pluggable view classes (flask.views.View or flask.views.MethodView).

Parameters:url – Relative URL for the view

New in version 1.0.4.

class BaseView(name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)[source]

Base administrative view.

Derive from this class to implement your administrative interface piece. For example:

from flask_admin import BaseView, expose
class MyView(BaseView):
    def index(self):
        return 'Hello World!'

Icons can be added to the menu by using menu_icon_type and menu_icon_value. For example:

admin.add_view(MyView(name='My View', menu_icon_type='glyph', menu_icon_value='glyphicon-home'))

Create Flask blueprint.

get_url(endpoint, **kwargs)[source]

Generate URL for the endpoint. If you want to customize URL generation logic (persist some query string argument, for example), this is right place to do it.

  • endpoint – Flask endpoint name
  • kwargs – Arguments for url_for
inaccessible_callback(name, **kwargs)[source]

Handle the response to inaccessible views.

By default, it throw HTTP 403 error. Override this method to customize the behaviour.


Override this method to add permission checks.

Flask-Admin does not make any assumptions about the authentication system used in your application, so it is up to you to implement it.

By default, it will allow access for everyone.


Override this method if you want dynamically hide or show administrative views from Flask-Admin menu structure

By default, item is visible in menu.

Please note that item should be both visible and accessible to be displayed in menu.

render(template, **kwargs)[source]

Render template

  • template – Template path to render
  • kwargs – Template arguments

Default view

class AdminIndexView(name=None, category=None, endpoint=None, url=None, template='admin/index.html', menu_class_name=None, menu_icon_type=None, menu_icon_value=None)[source]

Default administrative interface index page when visiting the /admin/ URL.

It can be overridden by passing your own view class to the Admin constructor:

class MyHomeView(AdminIndexView):
    def index(self):
        arg1 = 'Hello'
        return self.render('admin/myhome.html', arg1=arg1)

admin = Admin(index_view=MyHomeView())

Also, you can change the root url from /admin to / with the following:

admin = Admin(

Default values for the index page are:

  • If a name is not provided, ‘Home’ will be used.
  • If an endpoint is not provided, will default to admin
  • Default URL route is /admin.
  • Automatically associates with static folder.
  • Default template is admin/index.html


class Admin(app=None, name=None, url=None, subdomain=None, index_view=None, translations_path=None, endpoint=None, static_url_path=None, base_template=None, template_mode=None, category_icon_classes=None)[source]

Collection of the admin views. Also manages menu structure.

Add link to menu links collection.

Parameters:link – Link to add.

Add one or more links to the menu links collection.


admin.add_links(link1, link2, link3, link4)
Parameters:args – Argument list including the links to add.
add_menu_item(menu_item, target_category=None)[source]

Add menu item to menu tree hierarchy.

  • menu_item – MenuItem class instance
  • target_category – Target category name

Add a view to the collection.

Parameters:view – View to add.

Add one or more views to the collection.


admin.add_views(view1, view2, view3, view4)
Parameters:args – Argument list including the views to add.
init_app(app, index_view=None, endpoint=None, url=None)[source]

Register all views with the Flask application.

Parameters:app – Flask application instance

Return the menu hierarchy.

Return menu links.