middleware.py from django.utils.deprecation import MiddlewareMixin from django.shortcuts import render,redirect,reverse from django.shortcuts import HttpResponse class SessionAuth(MiddlewareMixin): def process_request(self,request): print("session认证开…