Flask框架后端开发常见错误处理(2018/11/14)

Flask常见错误与解决方法(By Wdx)

1.ValueError: urls must start with a leading slash数据库

这个错误缘由可能发生在全部路由相关地方,少加了一个'/'形成的。session

2.ImportError: cannot import name 'db'app

这个错误缘由是产生了循环导入问题,修改import的位置便可socket

3.AssertionError: View function mapping is overwriting an existing endpoint function: manager.check_permissionide

这个错误缘由是自定义的装饰器中没有使用functools模块下的wraps(func)修饰wrapper (func)url

4.socket.gaierror: [Errno -2] Name or service not knownspa

这个错误缘由是当发送邮件等事务发生时,虚拟机没联网事务

5.The method is not allowed for the requested URL.路由

这个错误缘由是路由书写时候,前一个路由没有写methods=['POST','GET']虚拟机

6.AttributeError: 'SQLAlchemy' object has no attribute 'commit'

这个错误缘由是db.session.commit(),可能忘记写session

7.RuntimeError: No application found. Either work inside a view function or push an application context.

这个错误缘由是应该写进视图模块中的代码约束,写到了表单模块中

8.TypeError: redirect() got an unexpected keyword argument 'id'

这个错误缘由可能不单单是重定向传错参数,还有可能只写了redirect,忘记写url_for

9.ERROR [root] Error: Can't locate revision identified by '8a92edbd0e8e'

这个问题是数据库中表alembic_version版本太低,直接删除

相关文章
相关标签/搜索