Просмотр исходного кода

Demonstrate template level caching. Fix #545 (#561)

Co-authored-by: Thibaud Colas <thibaudcolas@gmail.com>
Lupyana Mbembati 2 месяцев назад
Родитель
Сommit
fe57d734cc
2 измененных файлов с 7 добавлено и 4 удалено
  1. 1 0
      .gitignore
  2. 6 4
      bakerydemo/templates/blog/blog_index_page.html

+ 1 - 0
.gitignore

@@ -20,5 +20,6 @@ __pycache__
 .vagrant/
 /.vagrant/
 /Vagrantfile.local
+/bakerydemo/cache
 !.gitignore
 bakerydemo/collect_static

+ 6 - 4
bakerydemo/templates/blog/blog_index_page.html

@@ -1,5 +1,5 @@
 {% extends "base.html" %}
-{% load wagtailcore_tags navigation_tags wagtailimages_tags %}
+{% load wagtailcore_tags navigation_tags wagtailimages_tags wagtail_cache %}
 
 {% if tag %}
     {% block title %}
@@ -37,9 +37,11 @@
 
         <div class="blog-list">
             {% if posts %}
-                {% for blog in posts %}
-                    {% include "includes/card/blog-listing-card.html" %}
-                {% endfor %}
+                {% wagtailcache 500 posts %}
+                    {% for blog in posts %}
+                        {% include "includes/card/blog-listing-card.html" %}
+                    {% endfor %}
+                {% endwagtailcache %}
             {% else %}
                 <div class="col-md-12">
                     <p>Oh, snap. Looks like we were too busy baking to write any blog posts. Sorry.</p>