Created
March 10, 2010 20:17
-
-
Save jacobian/328320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### yabl/entries/templatetags/entry_tags.py | |
from django import template | |
from yabl.entries.models import Entry | |
register = template.Library() | |
@register.inclusion_tag('entries/latest_snippet.html') | |
def latest_entries(num): | |
return { | |
'entries': Entry.objects.order_by('-pub_date')[0:num] | |
} | |
##### yabl/templates/entries/latest_snippet.html | |
<ul> | |
{% for e in entries %} | |
<li>{{ e }}</li> | |
{% endfor %} | |
</ul> | |
##### yabl/templates/base.html | |
... | |
<h1>Latest entries:</h1> | |
{% load entry_tags %}{% latest_entries 2 %} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment