July 2019
Beginner to intermediate
302 pages
9h 38m
English
After implementing the preceding code, there is still an admin view that won't be completely user-protected and will be publicly available. This will be the admin home page. To make this available only to the admins, we have to inherit from AdminIndexView and implement is_accessible():
from flask_admin import AdminIndexView
class MyAdminIndexView(AdminIndexView):
def is_accessible(self):
return current_user.is_authenticated and current_user.is_admin()
Then, just pass this view to the admin object in the application's configuration as index_view, and we are done:
admin = Admin(app, index_view=views.MyAdminIndexView())
This approach makes all our admin views accessible only to the admin users. We can also implement any permission ...