檢查用戶狀態(tài)的更好方法是什么。假設(shè)halt我的數(shù)據(jù)庫模型中有一個列:halted = db.Column(db.Boolean(), nullable=False, server_default='0')如果我想停止此用戶帳戶,我會將值設(shè)置為true/1并且根據(jù)此值,某些內(nèi)容不會對他開放。處理這個問題的最佳方法是什么?Python 代碼:if user.halted == '1': return render_template('less_content.html')Jinja2 代碼:{% if user.halted is True %}<body> show less content...</body>{% else %}<body> show more content...</body>{% endif %}我的意思是在安全性方面有區(qū)別嗎?什么時候應(yīng)該使用一種方法而不是另一種方法?
Python 與 Jinja 驗證
慕運維8079593
2021-06-04 17:16:51