-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Django 3.2 cache compatibility #116
Comments
Temporary fix: --- ./dbtemplates/utils/cache.py.old 2021-04-06 17:18:12.741841778 +0300
+++ ./dbtemplates/utils/cache.py 2021-04-06 17:18:08.721937235 +0300
@@ -1,4 +1,5 @@
from django.core import signals
+from django.core.cache import caches
from django.contrib.sites.models import Site
from django.template.defaultfilters import slugify
@@ -9,13 +10,7 @@
"""
Compatibilty wrapper for getting Django's cache backend instance
"""
- 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
- signals.request_finished.connect(cache.close)
- return cache
+ return caches[settings.DBTEMPLATES_CACHE_BACKEND] |
my fix for support for django 3.2 without removing support for older versions --- 1 2021-04-14 10:54:09.984460911 +0200
+++ 2 2021-04-14 10:54:25.011612579 +0200
@@ -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 @@
"""
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
|
Hey all, to move this forward it's best to just open PRs that completely pass the tests. |
Please PR, the solution works fine |
Hi @jezdez
Please see the attached PR when you have a moment. There was an additional change for Django 3.2 compatibility other than the cache change. Tests look good on the PR 👍 |
…#116 Cache compat jazzband#116
Any news? |
Hi @afedosenko , I have contacted @jezdez as I need this package up and running; if @jezdez won't be able to answer, I'll create my maintained fork and keep it up as long as the original maintainers won't be available. |
PR #118 is merged and @mpasternak was added to the project in #121 (comment) so we should be able to get a release out soon 🤞 So let's close this. |
While using Django 3.2,
dbtemplates
throws the following error:The error stems from
dbtemplates
cache wrapper:django-dbtemplates/dbtemplates/utils/cache.py
Line 12 in ac86ca5
Side note of gratitude, this library has come in very handy for us at PBS. Thank you! 🙇
The text was updated successfully, but these errors were encountered: