Look like that you just created local variable can_create
, so you can try self.can_create = False
. But flask-admin
create one instance of View
and this can be problems with concurrency. However better separate logic for checking accessibility and changing view state. So probably better use next code:
class MyModelView(ModelView):
column_exclude_list = ['password']
def is_accessible(self):
return login.current_user.is_authenticated()
@property
def can_create(self):
return login.current_user.login == 'admin'