Goc*_*cht 6 python django caching
当我尝试访问缓存的URL时,我收到此错误.
我正在使用与Django一起缓存的per-view,当我第一次访问url时它工作正常,但是当它应该在缓存中时返回此错误.我使用FileBasedCache.这是我的设置:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/var/tmp/django_cache',
'TIMEOUT': 60,
'OPTIONS': {
'MAX_ENTRIES': 1000
}
}
}
MIDDLEWARE_CLASSES = settings.MIDDLEWARE_CLASSES + (
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware'
)
Run Code Online (Sandbox Code Playgroud)
在urls.py中是这样的:
...
cache_page(60*1)(MyClaseView.as_view())
...
Run Code Online (Sandbox Code Playgroud)
我已经查阅了目录权限,一切正常,那里有.djcache文件,所以它正在写入
顺便说一句,这个错误来自中间件(process_template_response),我在其中向context_data添加了一些数据.
这是Traceback:
Traceback (most recent call last):
File "/home/nexonet/.virtualenvs/esmidoctor/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 136, in get_response
response = middleware_method(request, response)
File "/home/nexonet/webapps/esmidoctor/esmidoctor/apps/common/middleware/template_article.py", line 12, in process_template_response
response.context_data['template_admin'] = 'panel/content/base.html'
AttributeError: 'TemplateResponse' object has no attribute 'context_data'
Run Code Online (Sandbox Code Playgroud)
提前致谢..!
| 归档时间: |
|
| 查看次数: |
1369 次 |
| 最近记录: |