flask.ext.superadmin.base
¶
Base View¶
-
flask.ext.superadmin.base.
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.
-
class
flask.ext.superadmin.base.
BaseView
(name=None, category=None, endpoint=None, url=None, static_folder=None)[source]¶ Base administrative view.
Derive from this class to implement your administrative interface piece. For example:
class MyView(BaseView): @expose('/') def index(self): return 'Hello World!'
Default view¶
-
class
flask.ext.superadmin.base.
AdminIndexView
(name=None, category=None, endpoint=None, url=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): @expose('/') def index(self): return render_template('adminhome.html') admin = Admin(index_view=MyHomeView)
Default values for the index page are following:
- If name is not provided, ‘Home’ will be used.
- If endpoint is not provided, will use
admin
- Default URL route is
/admin
. - Automatically associates with static folder.
Admin¶
-
class
flask.ext.superadmin.base.
Admin
(app=None, name=None, url=None, index_view=None, translations_path=None)[source]¶ Collection of the views. Also manages menu structure.
-
locale_selector
(f)[source]¶ Installs locale selector for current
Admin
instance.Example:
def admin_locale_selector(): return request.args.get('lang', 'en') admin = Admin(app) admin.locale_selector(admin_locale_selector)
It is also possible to use the
@admin
decorator:admin = Admin(app) @admin.locale_selector def admin_locale_selector(): return request.args.get('lang', 'en')
Or by subclassing the
Admin
:class MyAdmin(Admin): def locale_selector(self): return request.args.get('lang', 'en')
Return menu hierarchy.
-