I can't get cache to work inside a view. Can anybody point out where
I'm going wrong
In my settings file I have the following:-
CACHE_BACKEND = 'locmem:///'
The view is as follows:-
def offers(request):
from django.core.cache import cache
cache_time=60*60*24
cache_name = "offers"
object_list = cache.get(cache_name)
cache_working=" "
if not object_list:
cache_working="No"
offers=Offer.objects.all()
object_list={'offers':offers}
cache.set(cache_name,object_list,cache_time)
offers=object_list['offers']
template_name="offer/offer.html"
return render_to_response(template_name,
{'offers':offers,'cache_working':cache_working})
The variable "cache_working" always returns "NO".
Does this have anything to do with me working via localhost? My
middleware clasess are as follows (though I can't see why this would
make a difference)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---