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

    緣由:沒有建立相應的數據庫

相關文章
相關標籤/搜索