django 中间键实现部分请求不过滤

from django.utils.deprecation import MiddlewareMixin
from django.http import HttpResponseRedirect
class MyMiddle(MiddlewareMixin):
    def process_request(self,request):
       if '/RPMSapp/login/' != request.path and '/RPMSapp/login_check/'!= request.path:
            a = request.session.get('userName')
            if a == None:
                return HttpResponseRedirect('/RPMSapp/login/')

'/RPMSapp/login/'
/RPMSapp/login_check/'为登录的url
 
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页