2 回答

TA貢獻1789條經驗 獲得超10個贊
我猜你錯過了在你的視圖函數中設置第二個參數,消息的類別(它可以是error,warning無論如何..)flash()
flash(u'Invalid password provided', 'error')
不要忘記設置with_categories=true功能get_flashed_messages():
{% with messages = get_flashed_messages(with_categories=true) %} {# --HERE-- #}
{% if messages %}
{% for category, msg in messages %}
<div class="alert {{category}}">
<h1>{{category}}:</h1>
<h4>{{msg}}</h4>
</div>
{% endfor %}
{% endif %}
{% endwith %}

TA貢獻2041條經驗 獲得超4個贊
我找到了該怎么做,問題是我不得不提到我想在神社中使用類別
{% with messages = get_flashed_messages( with_categories=true ) %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, msg in messages %}
<div class="alert {{category}}">
<h4>{{msg}}</h4>
</div>
{% endfor %}
{% endif %}
{% endwith %}
添加回答
舉報