zoukankan      html  css  js  c++  java
  • login_required装饰器(1)

    login_required装饰器:
    
    如果没有登录:
    
    当请求http://192.168.137.3:9000/lockIndex/
    
    会跳转到http://192.168.137.3:9000/accounts/login/?next=/lockIndex/
    
    def lockIndex(req):
             print 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
             print '-----------------request.user.is_authenticated()';
             print req.user.is_authenticated()
             if not req.user.is_authenticated():
                  return redirect('/index')
             print '-----------------request.user.is_authenticated()';
    
             print '---------lockIndex--------------'
             from django.conf import settings
             print req.user
             print settings.LOGIN_URL
             print '---------lockIndex--------------'
             return render_to_response('lockIndex.html')
    
    		 
    [19/Sep/2018 10:15:06] "GET /lockIndex/ HTTP/1.1" 302 0
    [19/Sep/2018 10:15:06] "GET /accounts/login/?next=/lockIndex/ HTTP/1.1" 200 1189
    [19/Sep/2018 10:15:06] "GET /static/news/Css/Index/index.css HTTP/1.1" 304 0
    [19/Sep/2018 10:15:06] "GET /static/news/scan.jpg HTTP/1.1" 304 0
    [19/Sep/2018 10:15:06] "GET /static/news/login.jpg HTTP/1.1" 304 0
    Not Found: /favicon.ico
    [19/Sep/2018 10:15:06] "GET /favicon.ico HTTP/1.1" 404 7565
    
    根本不会调用这个lockIndex方法。	
  • 相关阅读:
    Linux中的防火墙
    Jinja2模板概述
    Ansible触发器-tag标签-忽略错误
    Ansible流程控制
    Ansible变量
    Play-book格式写法
    Redis哨兵(Sentinel)
    Redis 主从复制
    Redis介绍及安装
    Keepalived高可用集群搭建
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348983.html
Copyright © 2011-2022 走看看