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方法。	
  • 相关阅读:
    模拟黑客入侵,恶搞小伙伴的利器
    牛客网算法竞赛难题
    ybt ——1346【例4-7】亲戚
    FBI树
    noi2020第二题
    noi2020第一题
    Happiness
    YiJuWuLiaoDeHua
    挂掉了一个u盘
    NOIp2020
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348983.html
Copyright © 2011-2022 走看看