I am using Flask-Admin in conjunction with Flask-Login and mongoengine.
I wish to customize views depending on users. Hereafter, an example with can_create
, that allows model creation.
class MyModelView(ModelView):
column_exclude_list = ['password']
def is_accessible(self):
if (login.current_user.login != 'admin'):
can_create=False
return login.current_user.is_authenticated()
Such a piece of code has no effect: all users can still create, no difference between admin and non-admin users.
Thanks a lot for any hint on how it's possible to allow model creation only to a given user.