mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-03-16 22:20:28 +00:00
Fixed cache setting handling. Fixes issue #4.
This commit is contained in:
parent
e11c2ee71d
commit
ae6818f745
2 changed files with 7 additions and 9 deletions
|
|
@ -2,10 +2,12 @@ import posixpath
|
|||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
# If we are on Django 1.3 AND using the new CACHES setting...
|
||||
cache = getattr(settings, "CACHES", {}).get("dbtemplates",
|
||||
# .. or fall back to the old CACHE_BACKEND setting
|
||||
getattr(settings, "DBTEMPLATES_CACHE_BACKEND", None))
|
||||
if "dbtemplates" in getattr(settings, "CACHES", {}):
|
||||
# If we are on Django 1.3 AND using the new CACHES setting..
|
||||
cache = "dbtemplates"
|
||||
else:
|
||||
# ..or fall back to the old CACHE_BACKEND setting
|
||||
cache = getattr(settings, "DBTEMPLATES_CACHE_BACKEND", None)
|
||||
if not cache:
|
||||
raise ImproperlyConfigured("Please specify a dbtemplates "
|
||||
"cache backend in your settings.")
|
||||
|
|
|
|||
|
|
@ -9,11 +9,7 @@ from dbtemplates import settings
|
|||
|
||||
|
||||
def get_cache_backend():
|
||||
if "://" in settings.CACHE_BACKEND:
|
||||
cache = get_cache(settings.CACHE_BACKEND)
|
||||
else:
|
||||
cache = get_cache(**settings.CACHE_BACKEND)
|
||||
return cache
|
||||
return get_cache(settings.CACHE_BACKEND)
|
||||
|
||||
cache = get_cache_backend()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue