1、views 示例
代码语言:javascript复制from flask import render_template, redirect, url_for, Flask, flash, session, request
@admin.route("/account/del/<int:id>/", methods=["GET"])
@admin_login_req
def account_del(id=None):
from app.models import db
print(id)
account = Account.query.filter_by(id=id).first_or_404()
print(account)
db.session.delete(account)
db.session.commit()
flash("删除记录成功!", "ok") # 消息闪现
return redirect(url_for('admin.account_list', page=1))
2、模板示例
代码语言:javascript复制{% for msg in get_flashed_messages(category_filter=["ok"]) %}
<div class="king-notice2 king-notice-success notice-borders">
<i class="fa fa-check-circle"></i>
<div class="notice-text">
<p>{{ msg }}</p>
</div>
</div>
{% endfor %}
消息闪现参考文档:http://www.pythondoc.com/flask/patterns/flashing.html