get_flashed_messages()这个函数没听懂

来源:2-9 消息闪现

慕莱坞5224394

2021-04-04 19:22:00

1、get_flashed_messages()这个参数有什么?

2、参数都是什么意思,有没有默认值?

3、函数怎么使用?

写回答

1回答

好帮手慕燕燕

2021-04-05

同学,你好 !对同学的疑问做如下解答

1、get_flashed_messages()方法有两个参数,with_categories和category_filter

2、with_categories默认值是False,表示只返回消息文本,with_categories为True时,返回元组;category_filter默认值是空列表,用于消息过滤,例如get_flashed_messages(category_filter=['error'])只闪现error类型的消息

3、get_flashed_messages()用在模板中,在视图函数中定义消息闪现,然后在模板中使用get_flashed_messages()函数获取消息,参考如下代码

http://img.mukewang.com/climg/606ab7260908402204830200.jpg

http://img.mukewang.com/climg/606ab81609dcd73613620214.jpg

祝:学习愉快!

0

0 学习 · 3562 问题

查看课程