Skip to Content
Mastering Flask Web Development - Second Edition
book

Mastering Flask Web Development - Second Edition

by Daniel Gaspar, Jack Stouffer
October 2018
Intermediate to advanced
332 pages
8h 9m
English
Packt Publishing
Content preview from Mastering Flask Web Development - Second Edition

Creating basic admin pages

The BaseView class allows normal Flask pages to be added to your admin interface. This is normally the least used type of view in Flask Admin setups, but if you wish to include something like custom reporting with JavaScript charting libraries, you can do it with a base view alone. As expected, we are going to define our views in the admin/controllers.py file:

from flask.ext.admin import BaseView, expose 
 
class CustomView(BaseView): 
    @expose('/')    @login_required    @has_role('admin')
    def index(self): 
        return self.render('admin/custom.html') 
 
    @expose('/second_page')    @login_required    @has_role('admin')
    def second_page(self):
        return self.render('admin/second_page.html') 

In a subclass of BaseView, multiple views can be registered ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Flask Web Development, 2nd Edition

Flask Web Development, 2nd Edition

Miguel Grinberg
Flask Web Development

Flask Web Development

Miguel Grinberg

Publisher Resources

ISBN: 9781788995405Supplemental Content