Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Django templatetags example
ul>
{% for p in posts %}
<li><a href="{{ a.url }}">{{ a.title }}</a>
{% endfor %}
</ul>
# This should go in app/templatetags/app_tags.py
from django.template import Library
from app.models import Post
register = Library()
@register.inclusion_tag('app/_latest_posts.html')
def latest_posts():
posts = Post.objects.order_by('-date')[:6]
return locals()
{% load app_tags %}
// Lots of HTML
<div>
{% latest_posts %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.