From 8d8fb6e63435faa5de2d07a52812f23b1796a29d Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 23 Jan 2012 14:17:04 +0100 Subject: [PATCH] pictures cache fix --- apps/picture/models.py | 8 ++++---- wolnelektury/templates/catalogue/work-list.html | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/picture/models.py b/apps/picture/models.py index 0217d8bad..1e27ce68e 100644 --- a/apps/picture/models.py +++ b/apps/picture/models.py @@ -6,7 +6,7 @@ from django.conf import settings from django.core.files.storage import FileSystemStorage from django.utils.datastructures import SortedDict from django.template.loader import render_to_string -from django.core.cache import cache +from django.core.cache import get_cache from catalogue.utils import split_tags from django.utils.safestring import mark_safe from slughifi import slughifi @@ -172,12 +172,12 @@ class Picture(models.Model): return cache_key = "Picture.short_html/%d" % (self.id) - cache.delete(cache_key) + get_cache('permanent').delete(cache_key) def short_html(self): if self.id: cache_key = "Picture.short_html/%d" % (self.id) - short_html = cache.get(cache_key) + short_html = get_cache('permanent').get(cache_key) else: short_html = None @@ -191,5 +191,5 @@ class Picture(models.Model): {'picture': self, 'tags': tags})) if self.id: - cache.set(cache_key, short_html, catalogue.models.CACHE_FOREVER) + get_cache('permanent').set(cache_key, short_html) return mark_safe(short_html) diff --git a/wolnelektury/templates/catalogue/work-list.html b/wolnelektury/templates/catalogue/work-list.html index 34ecb5f0a..19ca7c71d 100755 --- a/wolnelektury/templates/catalogue/work-list.html +++ b/wolnelektury/templates/catalogue/work-list.html @@ -6,10 +6,10 @@
    {% for item in object_list %}
  1. - {% if object_type == 'Book' %} - {% book_short item %} - {% else %} + {% if item.short_html %} {{ item.short_html }} + {% else %} + {% book_short item %} {% endif %}
  2. {% endfor %} -- 2.20.1