from appconf import AppConf
from django.conf import settings


class ImageKitConf(AppConf):
    CACHEFILE_NAMER = 'imagekit.cachefiles.namers.hash'
    SPEC_CACHEFILE_NAMER = 'imagekit.cachefiles.namers.source_name_as_path'
    CACHEFILE_DIR = 'CACHE/images'
    DEFAULT_CACHEFILE_BACKEND = 'imagekit.cachefiles.backends.Simple'
    DEFAULT_CACHEFILE_STRATEGY = 'imagekit.cachefiles.strategies.JustInTime'

    DEFAULT_FILE_STORAGE = None

    CACHE_BACKEND = None
    CACHE_PREFIX = 'imagekit:'
    USE_MEMCACHED_SAFE_CACHE_KEY = True

    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'

            if settings.DEBUG:
                value = dummy_cache
            else:
                value = (
                    getattr(settings, 'CACHES', {}).get('default')
                    or getattr(settings, 'CACHE_BACKEND', None)
                    or dummy_cache
                )
        return value

    def configure_default_file_storage(self, value):
        if value is None:
            value = settings.DEFAULT_FILE_STORAGE
        return value

@@ -875,178 +875,448 @@
     
-if settings.DEBUG:%0A                value = dummy_cache%0A            else:%0A                value = (%0A                    getattr(settings, 'CACHES', %7B%7D).get('default')%0A    
+# DEFAULT_CACHE_ALIAS doesn't exist in Django%3C=1.2%0A            try:%0A                from django.core.cache import DEFAULT_CACHE_ALIAS as default_cache_alias%0A            except ImportError:%0A                default_cache_alias = 'default'%0A%0A            if settings.DEBUG:%0A                value = dummy_cache%0A            elif default_cache_alias in getattr(settings, 'CACHES', %7B%7D):%0A                value = default_cache_alias%0A            else:%0A
     
@@ -1327,18 +1327,23 @@
         
-or
+value =
  getattr
@@ -1379,61 +1379,24 @@
 one)
-%0A                    or dummy_cache%0A                )
+ or dummy_cache%0A
 %0A   

Fix cache backend fallback