Hey everyone, I'm having problems with caching a queryset and storing the 
results of the query in the cache so the queries don't run when the page 
loads.  I am caching and pickling the queryset, however I keep just storing 
the query but not the results of the query.

      I've read through the docs several times and still am not getting 
what I need. I am caching and pickling a query set via a management command 
which should be evaluated by django so the query is not executed on page 
load, it should use cached results at the time of the cache object 
creation. But the debug toolbar is showing that the queries are still 
running when the page loads. So I'm assuming I'm just caching the query and 
not the results. Below is my code, any help would be great, I've been stuck 
on this for a few days now... thanks.

management command to generate the cache key, value:

    images_query = ImageAssociations.objects.filter(place_id = 
place_id).order_by(-image_score')[:10]

    images = pickle.dumps(images_query)  

    cache.set('images', images, timeout=9999)


views.py

      images_cache = cache.get('images')

      images = pickle.loads(images_cache)

      args = {}

      args['images'] = images

      return render_to_response('place.html', args)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/47391c74-890a-43d8-a5e7-6a14b9bb33d1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to