1.配置文件
MIDDLEWARE = [
'django.middleware.cache.UpdateCacheMiddleware'
'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',
'django.middleware.cache.FetchFromCacheMiddleware',
]
CACHE_MIDDLEWARE_SECONDS = 20 # 设置超时时间20秒
第一行和最后一行,位置不能放错,只能放第一,和最后一行,
又报错是
ModuleNotFoundError: No module named ‘django.middleware.cache.UpdateCacheMiddlewaredjango’; ‘django.middleware.cache’ is not a package
因为:
这里的逗号没写