• 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方法。	
  • 相关阅读:
    架构设计的UML图形思考
    SymmetricDS文档翻译--【Chapter 3. 具体配置(Configuration)[section C]】
    LeetCodeOJ. String to Integer (atoi)
    jquery05 继承
    jquery 04
    jquery constructor(null)
    jquery js解析函数、函数直接调用
    jquery init 关系
    jquery constructor
    jQuery03
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348983.html
Copyright © 2020-2023  润新知