@register.simple_tag<EOL>def get_upcoming_events_count(days=<NUM_LIT>, featured=False):
from happenings.models import Event<EOL>start_period = today - datetime.timedelta(days=<NUM_LIT:2>)<EOL>end_period = today + datetime.timedelta(days=days)<EOL>if featured:<EOL><INDENT>return Event.objects.filter(<EOL>featured=True,<EOL>start_date__gte=start_period,<EOL>start_date__lte=end_period<EOL>).count()<EOL><DEDENT>return Event.objects.filter(start_date__gte=start_period, start_date__lte=end_period).count()<EOL>
Returns count of upcoming events for a given number of days, either featured or all
Usage:
{% get_upcoming_events_count DAYS as events_count %}
with days being the number of days you want, or 5 by default