Django中间件
Django框架流程图
Django中间件类似于是Django的保安,请求的时候需要先经过Django的七个中间件才能到达Django后端(urls,views,templates,models),当响应完也需要经过中间件才能到达web服务网关接口。
Django默认的七个中间件
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ]