I have a fully working Flask-Admin app that makes use of Flask-Login. In a number of places in my ModelView code, I make use of current_user
, and this has always worked. For example, I have
def on_model_change(self, form, model, is_created):
model.last_modified_by = current_user.get_id()
I'm now trying to disable editing on a field based on access level, and after I declare some form_args
, I added:
if current_user.access_level == 'USER':
form_widget_args = {'salary': {'disabled': True}}
This throws the error AttributeError: 'NoneType' object has no attribute 'access_level'
. Yet without this code, I go right into the on_model_change
I show above, and this successfully sets the last_modified_by
value.
What could be going on?