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方法。	

 

你可能感兴趣的:(cmdb(adminset))