Django 3.2 compatibility
This commit is contained in:
Michał Pasternak 2022-06-15 12:17:42 +02:00 committed by GitHub
commit 9486f0c78b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 15 deletions

View file

@ -65,7 +65,7 @@ class Command(BaseCommand):
tpl_dirs = app_template_dirs + DIRS tpl_dirs = app_template_dirs + DIRS
else: else:
tpl_dirs = DIRS + app_template_dirs tpl_dirs = DIRS + app_template_dirs
templatedirs = [d for d in tpl_dirs if os.path.isdir(d)] templatedirs = [str(d) for d in tpl_dirs if os.path.isdir(d)]
for templatedir in templatedirs: for templatedir in templatedirs:
for dirpath, subdirs, filenames in os.walk(templatedir): for dirpath, subdirs, filenames in os.walk(templatedir):

View file

@ -1,3 +1,4 @@
import django
from django.core import signals from django.core import signals
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify
@ -9,8 +10,12 @@ def get_cache_backend():
""" """
Compatibilty wrapper for getting Django's cache backend instance Compatibilty wrapper for getting Django's cache backend instance
""" """
from django.core.cache import _create_cache if django.VERSION[0] >= 3 and django.VERSION[1] >= 2:
cache = _create_cache(settings.DBTEMPLATES_CACHE_BACKEND) 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 # 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 # the end of a request cycle. If not implemented in a particular backend
# cache.close is a no-op # cache.close is a no-op

16
tox.ini
View file

@ -4,14 +4,11 @@ usedevelop = True
minversion = 1.8 minversion = 1.8
envlist = envlist =
flake8 flake8
py{35,36}-dj111 py3{6,7,8,9}-dj22
py{35,36,37}-dj21 py3{6,7,8,9}-dj32
py{35,36,37,38,39}-dj22
py{36,37,38,39}-dj{30,31}
[gh-actions] [gh-actions]
python = python =
3.5: py36
3.6: py36 3.6: py36
3.7: py37 3.7: py37
3.8: py38, flake8 3.8: py38, flake8
@ -19,7 +16,6 @@ python =
[testenv] [testenv]
basepython = basepython =
py35: python3.5
py36: python3.6 py36: python3.6
py37: python3.7 py37: python3.7
py38: python3.8 py38: python3.8
@ -29,12 +25,8 @@ setenv =
DJANGO_SETTINGS_MODULE = dbtemplates.test_settings DJANGO_SETTINGS_MODULE = dbtemplates.test_settings
deps = deps =
-r requirements/tests.txt -r requirements/tests.txt
dj111: Django<2.0
dj20: Django<2.1
dj21: Django<2.2
dj22: Django<2.3 dj22: Django<2.3
dj30: Django<3.1 dj32: Django<3.3
dj31: Django<3.2
djmain: https://github.com/django/django/archive/main.tar.gz#egg=django djmain: https://github.com/django/django/archive/main.tar.gz#egg=django
commands = commands =
@ -44,7 +36,7 @@ commands =
coverage xml coverage xml
[testenv:flake8] [testenv:flake8]
basepython = python3.8 basepython = python3.9
commands = flake8 dbtemplates commands = flake8 dbtemplates
deps = flake8 deps = flake8