使用flask_login会话与jinja2模板 [英] Using flask_login session with jinja2 templates
本文介绍了使用flask_login会话与jinja2模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题是:我应该如何识别用户是否在jinja2模板中登录?
current_user 变量添加到您的模板中:
<$> p $ p>
<$> p $ p>
{%if current_user.is_authenticated%}
...
{%else%}
...
{%endif%}
他们在文档。
I have simple jinja2 template with registration/login links, I should hide them when user logged in, I also use flask_login module for this stuff.
Question is: How should I identify is user logged in in jinja2 templates?
解决方案
Flask-Login adds the current_user
variable to your templates:
{% if current_user.is_authenticated %}
...
{% else %}
...
{% endif %}
They mention this briefly in the documentation.
这篇关于使用flask_login会话与jinja2模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文