在學習flask框架過程中遇到很多坑,很少能找到一些解決方案,現在記錄下來,作為一個參考,希望后面的人學習的人可以避免。作為菜鳥,大神勿噴
-
BUG1
ExtDeprecationWarning: Importing flask.ext.sqlalchemy is deprecated, use flask_sqlalchemy instead.
.format(x=modname), ExtDeprecationWarning解決辦法:
此錯誤信息出現在對 flask 進行拓展時導入包的方式上錯誤:from flask.ext.script import Manager
正確:from flask_script import Manager
-
BUG2
TypeError: 'bool' object is not callable
解決辦法:
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原因:沒有創建相應的數據庫