From 26c49eaa568b32c3f94a5ee3191f9c7f83d30982 Mon Sep 17 00:00:00 2001 From: weiyang Date: Fri, 8 Dec 2023 15:34:45 +0800 Subject: [PATCH] Fix Django support reference https://github.com/encode/django-rest-framework/pull/7513 Signed-off-by: weiyang --- ring/django.py | 14 ++++++++------ setup.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ring/django.py b/ring/django.py index 3e6221d..608469c 100644 --- a/ring/django.py +++ b/ring/django.py @@ -5,11 +5,6 @@ import warnings -import django - -_DJANGO_VERSION = getattr(django, "VERSION", (0, 0, 0)) -if _DJANGO_VERSION[0] >= 4: - raise ImportError("Django >= 4 is not supported yet") from django.core import cache as django_cache from django.http.request import HttpRequest @@ -297,9 +292,16 @@ def article_post_django(request): :see: :func:`django.views.decorators.cache.cache_page`. """ # noqa + + def dummy_get_response(request): + return None + middleware_class = CacheMiddleware middleware = middleware_class( - cache_timeout=timeout, cache_alias=cache, key_prefix=key_prefix + get_response=dummy_get_response, + cache_timeout=timeout, + cache_alias=cache, + key_prefix=key_prefix, ) return fbase.factory( diff --git a/setup.py b/setup.py index 489ee4c..efce989 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ def get_version(): "redis>=4.2.0;python_version>='3.0'", "requests", "diskcache>=4.1.0", - "django<4", + "django", "numpy", ] docs_require = [