1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | {% block related %}
<div id="related-posts"><h2>{% trans "Related posts" %}</h2>
{% for tag in object.get_tags %}
{% tagged_objects tag in blog.Post as relatedItems %}
{% if relatedItems|length_is:"0" %}
{% else %}
<h3>{{ tag }}</h3>
<ul>
{% for relatedItem in relatedItems|slice:":3" %}
<li><a href="{{ relatedItem.get_absolute_url }}">{{ relatedItem.name|typogrify }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
</div>
{% endblock %}
|
More like this
- Class Feeds DRY TemplateTag by gmandx 3 years ago
- Create new variables in templates by jmrbcu 5 years, 4 months ago
- PyIf Template Tag (Conditional Tag) by nstrite 6 years, 2 months ago
- Private Context Decorator by acdha 3 years, 9 months ago
- django-tagging clouds template tag by skam 6 years, 1 month ago
Comments