Django's templatetag “cache” doesn't cache the queryset in template
-
27-09-2019 - |
Question
I use cache tag like this :
{% cache 1200 special %}
<div id="recommended-topics" class="ui-ce ui-ce-simple">
{{aticle_list}}
</div>
{% endcache %}
I found that there is a key named template.cache.special.d41d8cd98f00b204e9800998ecf8427e
in memcache.
however, I still find django execute the query to get the article_list
why this doesn't work??
Solution
First place I would check is the view which loads that template. Are you doing a query in the view to populate article_list
?
If so, then your template cache may be working but you're still hitting the database to generate a queryset that's not being used.
If that's the case, the simplest solution would be to look at setting up per-view caches.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow