注销时出现django消息 [英] django message when logout

查看:127
本文介绍了注销时出现django消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦用户注销了该站点,它将重定向到主页,并在页面顶部显示U已成功注销的消息。任何人帮助我在主页上显示消息?

Once an user logged out of the site, it should redirect to the home page and to display the message as "U are successfully logged out" in the top of the page. Anyone help me in displaying message in home page?

推荐答案

尝试使用会话。可以更简单。

Try using sessions. Can be simpler.

在注销视图中,在会话变量中设置一个条目,如 session ['just_logged_out'] = True ,并在主页视图中检查变量。

In the logout view, set an entry in the session variable, like session['just_logged_out'] = True, and in the home page view, check for the variable.

try:
  just_logged_out = request.session.get('just_logged_out',False)
except:
  just_logged_out = False

在模板中,您可以使用

{% if just_logged_out %}  You are successfully logged out {% endif %}

这篇关于注销时出现django消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆