From 37220efe96cd8569a15ee3c9f7dbb18688c5885c Mon Sep 17 00:00:00 2001 From: loulous27 Date: Thu, 4 Dec 2025 16:47:23 +0100 Subject: [PATCH] Correction on cache --- photo21/settings.py | 2 +- photo21/views.py | 4 ++-- photologue/models.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/photo21/settings.py b/photo21/settings.py index bfce090..d1d4957 100644 --- a/photo21/settings.py +++ b/photo21/settings.py @@ -28,7 +28,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = "CHANGE ME" # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = True ALLOWED_HOSTS = [ "127.0.0.1", diff --git a/photo21/views.py b/photo21/views.py index 167e3d2..e2aef26 100644 --- a/photo21/views.py +++ b/photo21/views.py @@ -6,17 +6,17 @@ from django.contrib.auth import get_user_model from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpResponse from django.views.generic import ListView, View -from django.views.decorators.cache import cache_page from photologue.models import Gallery class MediaAccess(LoginRequiredMixin, View): - @cache_page(31*24*60*60) + def get(self, request, path): response = HttpResponse() # Content-type will be detected by nginx del response["Content-Type"] response["X-Accel-Redirect"] = "/protected/media/" + path + response['Cache-Control'] = 'max-age=%d' % 60*60*24*31 return response diff --git a/photologue/models.py b/photologue/models.py index 855eff7..eec4857 100644 --- a/photologue/models.py +++ b/photologue/models.py @@ -15,7 +15,7 @@ from django.conf import settings from django.core.exceptions import ValidationError from django.core.files.base import ContentFile from django.core.validators import RegexValidator -from django.core.cache import caches +from django.core.cache import cache from django.db import models from django.template.defaultfilters import slugify from django.urls import reverse @@ -25,7 +25,7 @@ from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ from PIL import Image, ImageFile, ImageFilter - +caches = cache logger = logging.getLogger("photologue.models")