摘要: 1,在主目录(项目目录)下新建中间件middleware.py文件 写入 1 from django.utils.deprecation import MiddlewareMixin 2 from django.http import HttpResponseRedirect 3 import js 阅读全文
posted @ 2019-11-10 16:04 mpython 阅读(276) 评论(0) 推荐(0)
摘要: 1,定义和注册中间件 在注册的中间件中使用: from django.http import HttpResponseRedirect '''下面的书写方法会陷入死循环,所以必须加判断条件只调用一次''' def process_request(self,request): return HttpR 阅读全文
posted @ 2019-11-10 11:05 mpython 阅读(320) 评论(0) 推荐(0)