flask-admin部署到linux报错 too many values to unpack (expected 2)
我把我的项目上传到linux环境后,解压之后,配置数据库及其app为
host=‘0.0.0.0’,port=5005
之后运行起来了,可是点击到自定义的model 就是各种报错,报错内容都是一样的;可是在我的个人window环境却完全没有问题,这是环境哪里有问题吗?
File "/root/app/esayblog/apps/templates/admin/lib.html", line 190, in template
{{ render_field(form, f, kwargs) }}
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/jinja2/runtime.py", line 579, in _invoke
rv = self._func(*arguments)
File "/root/app/esayblog/apps/templates/admin/lib.html", line 121, in template
{% if field(**kwargs) is not none %}{% set testlabel = field(**kwargs) %}
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/wtforms/fields/core.py", line 153, in __call__
return self.meta.render_field(self, kwargs)
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/wtforms/meta.py", line 56, in render_field
return field.widget(field, **render_kw)
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/flask_admin/form/widgets.py", line 28, in __call__
return super(Select2Widget, self).__call__(field, **kwargs)
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/wtforms/widgets/core.py", line 287, in __call__
for val, label, selected in field.iter_choices():
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/flask_admin/contrib/sqla/fields.py", line 168, in iter_choices
for pk, obj in self._get_object_list():
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/flask_admin/contrib/sqla/fields.py", line 102, in _get_object_list
self._object_list = [(text_type(get_pk(obj)), obj) for obj in query]
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/flask_admin/contrib/sqla/fields.py", line 102, in <listcomp>
self._object_list = [(text_type(get_pk(obj)), obj) for obj in query]
File "/root/.pyenv/versions/3.6.1/lib/python3.6/site-packages/flask_admin/contrib/sqla/fields.py", line 299, in get_pk_from_identity
cls, key = identity_key(instance=obj)
ValueError: too many values to unpack (expected 2)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于解决了!
原来的是同一个flask_sqlalchemy版本,但是linux版本和window版本的下的orm/mapper.py的一个方法返回的元组个数不一样;window版返回两个是正确的;linux版本返回三个,存在bugger,估计现在是刚更新的和flask_admin还没有同步:
window版的源码:
linux版本的:
所以把源码给改成一样的就可以了;
或者把他的调用方法给改了: