In a views I have this cache which is supposed to save some costly queries:
from django.core.cache import cache
LIST_CACHE_TIMEOUT = 120
....
topics = cache.get('forum_topics_%s' % forum_id)
if not topics:
topics = Topic.objects.select_related('creator') \
.filter(forum=forum_id).order_by("-created")
print 'forum topics not in cache', forum_id #Always printed out
cache.set('forum_topics_%s' % forum_id, topics, LIST_CACHE_TIMEOUT)
I don't have problem using this method to cache other queryset results and can not think of the reson of this strange behavior, so I appreciate your hints about this.