The current dependency for Flask-SuperAdmin is Flask-WTF>=0.9 which itself install wtforms >= 1.0.4.
As for today, version for Flask-WTF is 0.11, and wtforms is 2.0.2.
The following model crash:
class Agenda(Document):
image = ImageField()
Here is the crash:
Traceback (most recent call last):
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/model/base.py", line 266, in add
% self.model.__name__)
Exception: The database model for 'Agenda' should have an __init__ with all arguments set to defaults.
But flask-superadmin is hiding the original error with a custom raise. After just changing the source code, the original exception is:
Traceback (most recent call last):
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/base.py", line 37, in inner
return f(self, *args, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/model/base.py", line 260, in add
form = Form(obj=self.model())
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/form.py", line 212, in __call__
return type.__call__(cls, *args, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/form.py", line 18, in __init__
super(BaseForm, self).__init__(obj=obj, prefix=prefix, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_wtf/form.py", line 96, in __init__
*args, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/ext/csrf/form.py", line 21, in __init__
super(SecureForm, self).__init__(formdata, obj, prefix, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/form.py", line 272, in __init__
super(Form, self).__init__(self._unbound_fields, meta=meta_obj, prefix=prefix)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/form.py", line 52, in __init__
field = meta.bind_field(self, unbound_field, options)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/meta.py", line 27, in bind_field
return unbound_field.bind(form=form, **options)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/fields/core.py", line 346, in bind
return self.field_class(*self.args, **kw)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/flask_superadmin/form.py", line 125, in __init__
self._clear = self.clear_field.bind(form=None, name=self._clear_name, prefix=self._prefix, id=self._clear_id)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/fields/core.py", line 346, in bind
return self.field_class(*self.args, **kw)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/fields/core.py", line 693, in __init__
super(BooleanField, self).__init__(label, validators, **kwargs)
File "/home/tito/.envs/2caps-backend/lib/python2.7/site-packages/wtforms/fields/core.py", line 92, in __init__
raise TypeError("Must provide one of _form or _meta")
TypeError: Must provide one of _form or _meta
Which look like something new from the wforms in 2.0: "Class Meta paradigm allows customization of many aspects of WTForms".
I tried to debug it, but got lost into all the layers of abstraction in flask superadmin. The current fix is to downgrade wtforms to a version before 2.0, like 1.0.5.
The current dependency for
Flask-SuperAdmin
isFlask-WTF>=0.9
which itself installwtforms >= 1.0.4
.As for today, version for
Flask-WTF
is 0.11, andwtforms
is 2.0.2.The following model crash:
Here is the crash:
But flask-superadmin is hiding the original error with a custom raise. After just changing the source code, the original exception is:
Which look like something new from the wforms in 2.0: "Class Meta paradigm allows customization of many aspects of WTForms".
See http://wtforms.readthedocs.org/en/latest/meta.html