Work a compatibility implementation for Django 1.2

This commit is contained in:
Pierre Dulac 2015-10-31 18:51:07 +01:00
parent 6fabad9749
commit 97dc4b6cb2

View file

@ -23,10 +23,21 @@ class ImageKitConf(AppConf):
except ImportError:
default_cache_alias = 'default'
if default_cache_alias in getattr(settings, 'CACHES', {}):
caches = getattr(settings, 'CACHES', None)
if caches is None:
# Support Django<=1.2 there is no default `CACHES` setting
try:
from django.core.cache.backends.dummy import DummyCache
except ImportError:
dummy_cache = 'dummy://'
else:
dummy_cache = 'django.core.cache.backends.dummy.DummyCache'
return dummy_cache
if default_cache_alias in caches:
value = default_cache_alias
else:
raise ValueError("The default cache alias '%s' is not available in CACHES" % value)
raise ValueError("The default cache alias '%s' is not available in CACHES" % default_cache_alias)
return value