mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-03-16 22:20:28 +00:00
Get cache for Django>=3.2
This commit is contained in:
parent
24b5f469a2
commit
f45cd228f9
1 changed files with 7 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import django
|
||||
from django.core import signals
|
||||
from django.contrib.sites.models import Site
|
||||
from django.template.defaultfilters import slugify
|
||||
|
|
@ -9,8 +10,12 @@ def get_cache_backend():
|
|||
"""
|
||||
Compatibilty wrapper for getting Django's cache backend instance
|
||||
"""
|
||||
from django.core.cache import _create_cache
|
||||
cache = _create_cache(settings.DBTEMPLATES_CACHE_BACKEND)
|
||||
if django.VERSION[0] >= 3 and django.VERSION[1] >= 2:
|
||||
from django.core.cache import caches
|
||||
cache = caches.create_connection(settings.DBTEMPLATES_CACHE_BACKEND)
|
||||
else:
|
||||
from django.core.cache import _create_cache
|
||||
cache = _create_cache(settings.DBTEMPLATES_CACHE_BACKEND)
|
||||
# Some caches -- python-memcached in particular -- need to do a cleanup at
|
||||
# the end of a request cycle. If not implemented in a particular backend
|
||||
# cache.close is a no-op
|
||||
|
|
|
|||
Loading…
Reference in a new issue