TaleLin / lin-cms-flask

🎀A simple and practical CMS implememted by Flask
http://doc.cms.talelin.com/
Other
832 stars 216 forks source link

cms端查询用户列表报错 #135

Closed LRboyz closed 3 years ago

LRboyz commented 3 years ago

cms查询用户列表接口500出错

报错信息如下: 127.0.0.1 - - [19/Jan/2021 22:16:44] "GET /cms/admin/users?count=10&page=0 HTTP/1.1" 500 - Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 2464, in call return self.wsgi_app(environ, start_response) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app response = self.handle_exception(e) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, kwargs))) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception reraise(exc_type, exc_value, tb) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(args, kwargs))) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 1822, in handle_user_exception return handler(e) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/lin/init.py", line 269, in handler raise e File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](req.view_args) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/lin/jwt.py", line 38, in wrapper return fn(args, kwargs) File "/Users/liurui/Desktop/lin-cms-flask/app/api/cms/admin.py", line 103, in get_admin_users groups = [group_dict[group_id] for group_id in group_id_list] File "/Users/liurui/Desktop/lin-cms-flask/app/api/cms/admin.py", line 103, in groups = [group_dict[group_id] for group_id in group_id_list] KeyError: 1 请问 如何解决

sunlin92 commented 3 years ago

你好,看起来操作调用了一个不存在的用户组id,猜测手动变更过数据库记录。 如果是其它原因,建议参考issue bug模版来补充更多信息,帮助我们复现bug定位问题,谢谢

LRboyz commented 3 years ago

您好,请问可以添加一个添加超级管理员的脚本吗,因为程序运行后需要手动设置超级管理员账号比较麻烦,所以导致了这个错误

sunlin92 commented 3 years ago

flask db init命令可以帮助你完成这个操作,对应代码存放在app/cli/db/init.py,也可以根据需要修改它