Upgrading Caching Django 1.2 to 1.3

July 30, 2011

I was upgrading a site from Django 1.2 to 1.3, and I got the following error when I requested my homepage:

Traceback (most recent call last):

  File "/home/drumcoder/web/drumcoder/django/core/servers/basehttp.py", line 283, in run
    self.result = application(self.environ, self.start_response)

  File "/home/drumcoder/web/drumcoder/django/contrib/staticfiles/handlers.py", line 68, in __call__
    return self.application(environ, start_response)

  File "/home/drumcoder/web/drumcoder/django/core/handlers/wsgi.py", line 250, in __call__
    self.load_middleware()

  File "/home/drumcoder/web/drumcoder/django/core/handlers/base.py", line 53, in load_middleware
    mw_instance = mw_class()

  File "/home/drumcoder/web/drumcoder/django/middleware/cache.py", line 70, in __init__
    self.cache = get_cache(self.cache_alias)

  File "/home/drumcoder/web/drumcoder/django/core/cache/__init__.py", line 173, in get_cache
    backend, location, params = parse_backend_conf(backend, **kwargs)

  File "/home/drumcoder/web/drumcoder/django/core/cache/__init__.py", line 131, in parse_backend_conf
    mod_path, cls_name = backend.rsplit('.', 1)

ValueError: need more than 1 value to unpack

The cause was because I had the following settings in my settings.py:

CACHE_MIDDLEWARE_ALIAS = 'drumcoder'

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
    }
}

In Django 1.3, the CACHE_MIDDLEWARE_ALIAS setting tells the cache software to look for a CACHES backend called drumcoder. I only have one called default. I removed the CACHE_MIDDLEWARE_ALIAS line and all was well.

Tags: django cache