2011-02-27 34 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