1. Colin Copeland
  2. django-basic-events

Source

django-basic-events / events / templatetags / event_tags.py

from django import template
from django.utils.safestring import mark_safe

from events import models

register = template.Library()


@register.inclusion_tag('events/tags/lastest_events.html')
def lastest_events(count):
    events = None
    if isinstance(count, int):
        events = models.Event.objects.order_by('-begin_date')[:count]
    return {'events': events}