2011-02-27 86 views
0
  1. 我想知道是否可以删除模板缓存中创建的缓存内容。我想从我的视图中删除它。我在我的模板中有{% cache 500 cache_name sites.number %} 是否有可能删除视图中的所有“cache_name”缓存内容,例如,在执行某些操作时?我想使用per-vie cache。我做的一切所描述的内容,但是当我打电话:@cache_page(3600, cache="cache_name")我得到错误:一些缓存问题

Exception Type: ValueError Exception Value: need more than 1 value to unpack

(以下是回溯)

我想实现的是缓存我所有的模板块或查看并有可能在执行某些操作时删除与其连接的所有缓存。分页包含

回溯

Environment: 


Request Method: GET 
Request URL: http://localhost:8000/portfolio/ 

Django Version: 1.3 beta 1 SVN-15661 
Python Version: 2.7.1 
Installed Applications: 
['django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.admin', 
'apps.index'] 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware') 


Traceback: 
File "E:\Python\django\core\handlers\base.py" in get_response 
    101.        request.path_info) 
File "E:\Python\django\core\urlresolvers.py" in resolve 
    252.      sub_match = pattern.resolve(new_path) 
File "E:\Python\django\core\urlresolvers.py" in resolve 
    252.      sub_match = pattern.resolve(new_path) 
File "E:\Python\django\core\urlresolvers.py" in resolve 
    158.    return ResolverMatch(self.callback, args, kwargs, self.name) 
File "E:\Python\django\core\urlresolvers.py" in _get_callback 
    164.    self._callback = get_callable(self._callback_str) 
File "E:\Python\django\utils\functional.py" in wrapper 
    124.   result = func(*args) 
File "E:\Python\django\core\urlresolvers.py" in get_callable 
    91.     lookup_view = getattr(import_module(mod_name), func_name) 
File "E:\Python\django\utils\importlib.py" in import_module 
    35.  __import__(name) 
File "E:\Python\apps\index\views.py" in <module> 
    29. @cache_page(600, cache='my_cache') 
File "E:\Python\django\views\decorators\cache.py" in cache_page 
    58.    return decorator_from_middleware_with_args(CacheMiddleware)(cache_timeout=args[0], cache_alias=cache_alias, key_prefix=key_prefix) 
File "E:\Python\django\utils\decorators.py" in _make_decorator 
    81.   middleware = middleware_class(*m_args, **m_kwargs) 
File "E:\Python\django\middleware\cache.py" in __init__ 
    204.   self.cache = get_cache(self.cache_alias, **cache_kwargs) 
File "E:\Python\django\core\cache\__init__.py" in get_cache 
    173.    backend, location, params = parse_backend_conf(backend, **kwargs) 
File "E:\Python\django\core\cache\__init__.py" in parse_backend_conf 
    131.   mod_path, cls_name = backend.rsplit('.', 1) 

Exception Type: ValueError at /portfolio/ 
Exception Value: need more than 1 value to unpack 

回答

0

您正在使用什么版本的Django的?参数“缓存”仅在开发版本中可用。如果您使用的是Django 1.2,则只能使用“key_prefix”。

+0

,你可以在我跟踪的第一篇文章见:Django的版本:1.3 Beta 1的SVN-15661 – robos85 2011-03-06 13:44:29