Flask爬坑筆記


在學習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

    原因:沒有創建相應的數據庫


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM