Flask爬坑笔记

在学习flask框架过程当中遇到不少坑,不多能找到一些解决方案,如今记录下来,做为一个参考,但愿后面的人学习的人能够避免。做为菜鸟,大神勿喷

  • BUG1sql

    ExtDeprecationWarning: Importing flask.ext.sqlalchemy is deprecated, use flask_sqlalchemy instead.
    .format(x=modname), ExtDeprecationWarning数据库

    解决办法:
    此错误信息出如今对 flask 进行拓展时导入包的方式上flask

    错误:from flask.ext.script import Manager多线程

    正确:from flask_script import Manager框架

  • BUG2函数

    TypeError: 'bool' object is not callablepost

    解决办法
    flask_login 0.3以后将authenticated从函数更改成属性
    把g.user.is_authenticated() 修改成g.user.is_authenticated学习

  • BUG3编码

    第三方模块登陆(OPenid)登陆出错线程

    Login requested for OpenID="https://me.yahoo.com", remember_me=False
    解决办法暂时没找到 改用本地登陆

    缘由:得到用户时出错

  • BUG4
    **IndentationError: unexpected indent **

    缘由:多是tab和空格没对齐的问题,须要检查下tab和空格

+BUG5

TypeError: Unicode-objects must be encoded before hashing

缘由:未进行编码 <models ->> avatar >

  • BUG6

    jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'author'

    缘由:user中post传参错误

  • BUG7
    sqlalchemy.exc.IntegrityError

    缘由:数据库中的用户名不惟一

思考:为防止数据重复出现,在两个或者多线程/进程进行并行存取数据库时,怎么解决?

  • BUG8
    sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table

    缘由:没有建立相应的数据库

相关文章
相关标签/搜索