Reduce number of queries in blog_page (#9857)

pull/9862/head
Jhonatan Lopes 2023-01-06 11:48:24 -03:00 zatwierdzone przez Matt Westcott
rodzic 99eaef6ee6
commit fb4837371f
2 zmienionych plików z 11 dodań i 8 usunięć

Wyświetl plik

@ -679,6 +679,7 @@ Contributors
* Vallabh Tiwari * Vallabh Tiwari
* dr-rompecabezas * dr-rompecabezas
* Rishabh jain * Rishabh jain
* Jhonatan Lopes
Translators Translators
=========== ===========

Wyświetl plik

@ -694,14 +694,16 @@ Edit one of your `BlogPage` instances, and you should now be able to tag posts:
To render tags on a `BlogPage`, add this to `blog_page.html`: To render tags on a `BlogPage`, add this to `blog_page.html`:
```html+django ```html+django
{% if page.tags.all.count %} {% with tags=page.tags.all %}
<div class="tags"> {% if tags %}
<h3>Tags</h3> <div class="tags">
{% for tag in page.tags.all %} <h3>Tags</h3>
<a href="{% slugurl 'tags' %}?tag={{ tag }}"><button type="button">{{ tag }}</button></a> {% for tag in tags %}
{% endfor %} <a href="{% slugurl 'tags' %}?tag={{ tag }}"><button type="button">{{ tag }}</button></a>
</div> {% endfor %}
{% endif %} </div>
{% endif %}
{% endwith %}
``` ```
Notice that we're linking to pages here with the builtin `slugurl` Notice that we're linking to pages here with the builtin `slugurl`