getting the related entries with a templatetag using django-tagging

 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

  1. django-tagging clouds template tag by skam 4 years, 10 months ago
  2. TaggedManager and TaggedQuerySet with chainable tagged() methods implemented with django-tagging by fish2000 1 year, 11 months ago
  3. paginator using url tag by fivethreeo 4 years, 5 months ago
  4. Parse TemplateTag Variables Safely by evan_schulz 3 years, 6 months ago
  5. View to retrieve objects meeting a complex tag query by nathangeffen 1 year, 1 month ago

Comments

(Forgotten your password?)