From 4efdade36aa23d3a6ca2ed6b4e0f81584056e0f5 Mon Sep 17 00:00:00 2001 From: Nikita Bolotin Date: Fri, 20 Jun 2025 10:45:54 +0100 Subject: [PATCH 1/2] Fix Django 4.0 compatibility issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix InvalidCacheBackendError import location - Import from django.core.cache.backends.base instead of django.core.cache - This resolves compatibility issues with Django 4.0+ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- django_elasticache/memcached.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_elasticache/memcached.py b/django_elasticache/memcached.py index a78fbd7..31b2030 100644 --- a/django_elasticache/memcached.py +++ b/django_elasticache/memcached.py @@ -3,7 +3,7 @@ """ import socket from functools import wraps -from django.core.cache import InvalidCacheBackendError +from django.core.cache.backends.base import InvalidCacheBackendError from django.core.cache.backends.memcached import PyLibMCCache from .cluster_utils import get_cluster_info From 418f9a3a7ff1e2505288740bead2aa1c45cf25f1 Mon Sep 17 00:00:00 2001 From: Nikita Bolotin Date: Fri, 20 Jun 2025 15:45:38 +0100 Subject: [PATCH 2/2] Fix Django 4.0 smart_text compatibility issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace smart_text with smart_str in cluster_utils.py - smart_text was deprecated and removed in Django 4.0 - This completes the Django 4.0 compatibility fixes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- django_elasticache/cluster_utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/django_elasticache/cluster_utils.py b/django_elasticache/cluster_utils.py index 60594ca..ff1fe09 100644 --- a/django_elasticache/cluster_utils.py +++ b/django_elasticache/cluster_utils.py @@ -2,7 +2,7 @@ utils for discovery cluster """ from distutils.version import StrictVersion -from django.utils.encoding import smart_text +from django.utils.encoding import smart_str import re from telnetlib import Telnet @@ -35,7 +35,7 @@ def get_cluster_info(host, port, ignore_cluster_errors=False): if len(version_list) not in [2, 3] or version_list[0] != b'VERSION': raise WrongProtocolData('version', res) version = version_list[1] - if StrictVersion(smart_text(version)) >= StrictVersion('1.4.14'): + if StrictVersion(smart_str(version)) >= StrictVersion('1.4.14'): cmd = b'config get cluster\n' else: cmd = b'get AmazonElastiCache:cluster\n' @@ -50,8 +50,8 @@ def get_cluster_info(host, port, ignore_cluster_errors=False): return { 'version': version, 'nodes': [ - '{0}:{1}'.format(smart_text(host), - smart_text(port)) + '{0}:{1}'.format(smart_str(host), + smart_str(port)) ] } @@ -67,8 +67,8 @@ def get_cluster_info(host, port, ignore_cluster_errors=False): try: for node in ls[2].split(b' '): host, ip, port = node.split(b'|') - nodes.append('{0}:{1}'.format(smart_text(ip or host), - smart_text(port))) + nodes.append('{0}:{1}'.format(smart_str(ip or host), + smart_str(port))) except ValueError: raise WrongProtocolData(cmd, res) return {