mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Do not take a decision on which cache to use in DEBUG mode
maybe the developer wants to test his cache configuration locally, or maybe he has to test different types of caches, we just don't know
This commit is contained in:
parent
0a0708d2d6
commit
fbf15befb8
1 changed files with 2 additions and 11 deletions
|
|
@ -17,25 +17,16 @@ class ImageKitConf(AppConf):
|
|||
|
||||
def configure_cache_backend(self, value):
|
||||
if value is None:
|
||||
try:
|
||||
from django.core.cache.backends.dummy import DummyCache
|
||||
except ImportError:
|
||||
dummy_cache = 'dummy://'
|
||||
else:
|
||||
dummy_cache = 'django.core.cache.backends.dummy.DummyCache'
|
||||
|
||||
# DEFAULT_CACHE_ALIAS doesn't exist in Django<=1.2
|
||||
try:
|
||||
from django.core.cache import DEFAULT_CACHE_ALIAS as default_cache_alias
|
||||
except ImportError:
|
||||
default_cache_alias = 'default'
|
||||
|
||||
if settings.DEBUG:
|
||||
value = dummy_cache
|
||||
elif default_cache_alias in getattr(settings, 'CACHES', {}):
|
||||
if default_cache_alias in getattr(settings, 'CACHES', {}):
|
||||
value = default_cache_alias
|
||||
else:
|
||||
value = getattr(settings, 'CACHE_BACKEND', None) or dummy_cache
|
||||
raise ValueError("The default cache alias '%s' is not available in CACHES" % value)
|
||||
|
||||
return value
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue