Excluding a field results in AttributeError.
brotatos opened this issue · 1 comments
brotatos commented
The error:
Traceback (most recent call last):
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask_superadmin/model/base.py", line 325, in edit
Form = self.get_form()
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask_superadmin/model/base.py", line 177, in get_form
converter=converter)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/flask_superadmin/model/backends/sqlalchemy/orm.py", line 178, in model_form
converter=converter)
File "/home/robin/github/ieee/venv/lib/python2.7/site-packages/wtforms/ext/sqlalchemy/orm.py", line 289, in model_form
exclude.append(prop.key)
AttributeError: 'tuple' object has no attribute 'append'
And my Admin Views:
class MyAdminIndexView(AdminIndexView):
def is_accessible(self):
return current_user.is_authenticated() \
and current_user.get_role() != 'user'
# Limit view to only officers and admin.
class MyAdminView(ModelAdmin):
def is_accessible(self):
return current_user.is_authenticated() \
and current_user.get_role() != 'user'
class UserView(MyAdminView):
session = db.session
#readonly_fields = ('password',)
exclude = ('password',)
list_display = ('name', 'email', 'role')
Check out the __init.py__
to see how the views are added.
brotatos commented
Nevermind, it was just me using a tuple instead of a list.