注销后禁用浏览器“返回”按钮? [英] Disable browser 'Back' button after logout?

查看:131
本文介绍了注销后禁用浏览器“返回”按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用python与django我想重定向用户登录页面,当他点击退出按钮退出后。如何实现这一点?在哪里写代码?



要测试django管理员是否处理这个...我登录到django admin..logged,然后点击按钮,我可以看到上一页。为什么django管理员不处理这个。



这是django管理员注销的ccode:

 def logout(request):

从请求中删除经过身份验证的用户ID,并刷新
会话数据

request.session.flush()
if hasattr(request,'user'):
from django.contrib.auth.models import AnonymousUser
request.user = AnonymousUser()


解决方案

最后找到解决方案:

 从django.views.decorators.cache导入cache_control 

@cache_control(no_cache = True,must_revalidate = True)
def func()
#some code
return

这将强制浏览器向服务器发出请求。


I am using python with django i want redirect users to login page when he clicks back button after logout. How to achieve this? where to write the code?

To test whether django admin handles this..i logged into django admin..logged out and then hit back button and i am able to see the previous page. Why django admin does not handle this.

This is the ccode for logout in django admin:

def logout(request):
  """
 Removes the authenticated user's ID from the request and flushes their
 session data.
 """
 request.session.flush()
 if hasattr(request, 'user'):
     from django.contrib.auth.models import AnonymousUser
     request.user = AnonymousUser()

解决方案

Finally found the solution:

from django.views.decorators.cache import cache_control

@cache_control(no_cache=True, must_revalidate=True)
def func()
  #some code
  return

This will force the browser to make request to server.

这篇关于注销后禁用浏览器“返回”按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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