Restricting one view on Flask-Admin? Restricting one view on Flask-Admin? flask flask

Restricting one view on Flask-Admin?


I'll assume that you subclassed BaseView to create your admin view and that you are using Flask-login.

Then override the is_accessible method in your view class, to check the current user's quality:

from flask.ext.admin.base import BaseViewfrom flask.ext.login import current_userclass MyView(BaseView):    def is_accessible(self):        return current_user.testlevel == 'admin'

Hope this helps!