November 2015
Beginner
250 pages
5h 16m
English
Flask-Admin provides a convenient interface for managing static assets (or other files on disk) as an extension to the admin dashboard. Let's add a FileAdmin to our site that will allow us to upload or modify files in our application's static directory.
Open admin.py and import the following module at the top of the file:
from flask.ext.admin.contrib.fileadmin import FileAdmin
Then, below the various ModelView implementations, add the following highlighted lines of code:
class BlogFileAdmin(FileAdmin): pass admin = Admin(app, 'Blog Admin') admin.add_view(EntryModelView(Entry, db.session)) admin.add_view(SlugModelView(Tag, db.session)) admin.add_view(UserModelView(User, db.session)) admin.add_view( BlogFileAdmin(app.config['STATIC_DIR'], ...
Read now
Unlock full access