django 有没有类似于flask的before_request
django的views.py中有木有像flask那样的before_request的操作?
gurgu
9 years, 9 months ago
Answers
Django的before_request叫
Middleware
。
看看
settings.py
会有类似下面的内容:
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
"core.middleware.TemplateForDeviceMiddleware",
)
御坂御坂御坂
answered 9 years, 9 months ago