Skip to content

Commit 373dbcf

Browse files
authored
Merge pull request #1 from wamberg/cache-compat-#116
Cache compat jazzband#116
2 parents 550609b + 376f339 commit 373dbcf

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

dbtemplates/management/commands/sync_templates.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def handle(self, **options):
6565
tpl_dirs = app_template_dirs + DIRS
6666
else:
6767
tpl_dirs = DIRS + app_template_dirs
68-
templatedirs = [d for d in tpl_dirs if os.path.isdir(d)]
68+
templatedirs = [str(d) for d in tpl_dirs if os.path.isdir(d)]
6969

7070
for templatedir in templatedirs:
7171
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

+4-12
Original file line numberDiff line numberDiff line change
@@ -4,22 +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
10-
py{36,37,38,39}-dj{30,31}
7+
py3{6,7,8,9}-dj22
8+
py3{6,7,8,9}-dj32
119

1210
[gh-actions]
1311
python =
14-
3.5: py36
1512
3.6: py36
1613
3.7: py37
1714
3.8: py38, flake8
1815
3.9: py39
1916

2017
[testenv]
2118
basepython =
22-
py35: python3.5
2319
py36: python3.6
2420
py37: python3.7
2521
py38: python3.8
@@ -29,12 +25,8 @@ setenv =
2925
DJANGO_SETTINGS_MODULE = dbtemplates.test_settings
3026
deps =
3127
-r requirements/tests.txt
32-
dj111: Django<2.0
33-
dj20: Django<2.1
34-
dj21: Django<2.2
3528
dj22: Django<2.3
36-
dj30: Django<3.1
37-
dj31: Django<3.2
29+
dj32: Django<3.3
3830
djmain: https://github.com/django/django/archive/main.tar.gz#egg=django
3931

4032
commands =
@@ -44,7 +36,7 @@ commands =
4436
coverage xml
4537

4638
[testenv:flake8]
47-
basepython = python3.8
39+
basepython = python3.9
4840
commands = flake8 dbtemplates
4941
deps = flake8
5042

0 commit comments

Comments
 (0)