Skip to content

Commit 0589be0

Browse files
authored
Merge pull request #2 from wamberg/cache-compat-#116
Cache compat jazzband#116
2 parents ec4ac6b + 272af3c commit 0589be0

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

dbtemplates/management/commands/sync_templates.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def handle(self, **options):
6969
tpl_dirs = app_template_dirs + DIRS
7070
else:
7171
tpl_dirs = DIRS + app_template_dirs
72-
templatedirs = [d for d in tpl_dirs if os.path.isdir(d)]
72+
templatedirs = [str(d) for d in tpl_dirs if os.path.isdir(d)]
7373

7474
for templatedir in templatedirs:
7575
for dirpath, subdirs, filenames in os.walk(templatedir):

dbtemplates/utils/cache.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import django
12
from django.core import signals
23
from django.contrib.sites.models import Site
34
from django.template.defaultfilters import slugify
@@ -9,8 +10,12 @@ def get_cache_backend():
910
"""
1011
Compatibilty wrapper for getting Django's cache backend instance
1112
"""
12-
from django.core.cache import _create_cache
13-
cache = _create_cache(settings.DBTEMPLATES_CACHE_BACKEND)
13+
if django.VERSION[0] >= 3 and django.VERSION[1] >= 2:
14+
from django.core.cache import caches
15+
cache = caches.create_connection(settings.DBTEMPLATES_CACHE_BACKEND)
16+
else:
17+
from django.core.cache import _create_cache
18+
cache = _create_cache(settings.DBTEMPLATES_CACHE_BACKEND)
1419
# Some caches -- python-memcached in particular -- need to do a cleanup at
1520
# the end of a request cycle. If not implemented in a particular backend
1621
# cache.close is a no-op

tox.ini

+5-9
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ usedevelop = True
44
minversion = 1.8
55
envlist =
66
flake8
7-
py{35,36}-dj111
8-
py{35,36,37}-dj21
9-
py{35,36,37,38,39}-dj22
7+
py3{6,7,8,9}-dj22
8+
py3{6,7,8,9}-dj3{1,2}
109

1110
[gh-actions]
1211
python =
13-
3.5: py36
1412
3.6: py36
1513
3.7: py37
1614
3.8: py38, flake8
1715
3.9: py39
1816

1917
[testenv]
2018
basepython =
21-
py35: python3.5
2219
py36: python3.6
2320
py37: python3.7
2421
py38: python3.8
@@ -28,10 +25,9 @@ setenv =
2825
DJANGO_SETTINGS_MODULE = dbtemplates.test_settings
2926
deps =
3027
-r requirements/tests.txt
31-
dj111: Django<2.0
32-
dj20: Django<2.1
33-
dj21: Django<2.2
3428
dj22: Django<2.3
29+
dj31: Django<3.2
30+
dj32: Django<3.3
3531
djmain: https://github.com/django/django/archive/main.tar.gz#egg=django
3632

3733
commands =
@@ -41,7 +37,7 @@ commands =
4137
coverage xml
4238

4339
[testenv:flake8]
44-
basepython = python3.8
40+
basepython = python3.9
4541
commands = flake8 dbtemplates
4642
deps = flake8
4743

0 commit comments

Comments
 (0)