# HG changeset patch # User Bob Mourlam # Date 1320635782 21600 # Node ID 5c0f9d80442e93450beba745e35f5fbef16b2eac # Parent b9d6f6d930a9ed9d31a31ffd1f3dcfa4329cb1cb I added a news template tag that's a blatant rip off of Chris' review one. diff -r b9d6f6d930a9 -r 5c0f9d80442e bns_website/news/templatetags/news_tags.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/news/templatetags/news_tags.py Sun Nov 06 21:16:22 2011 -0600 @@ -0,0 +1,11 @@ +from django import template +from news.models import News + +register = template.Library() + +""" +Display a list of the last num_to_display news items. +""" +@register.inclusion_tag('news/news_tag.html') +def list_news(num_to_display): + return {'object_list': News.objects.all()[:num_to_display]} \ No newline at end of file diff -r b9d6f6d930a9 -r 5c0f9d80442e bns_website/templates/home.html --- a/bns_website/templates/home.html Sun Nov 06 20:28:25 2011 -0600 +++ b/bns_website/templates/home.html Sun Nov 06 21:16:22 2011 -0600 @@ -1,6 +1,6 @@ {% extends 'base.html' %} {% load url from future %} -{% load core_tags reviews_tags %} +{% load core_tags reviews_tags news_tags%} {% block title %}Home{% endblock %} {% block custom_meta %} @@ -85,12 +85,7 @@

News

-

This box shows links to the 5 most recent news items.

- + {% list_news 5 %}


All News »

diff -r b9d6f6d930a9 -r 5c0f9d80442e bns_website/templates/news/news_tag.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/templates/news/news_tag.html Sun Nov 06 21:16:22 2011 -0600 @@ -0,0 +1,6 @@ +{% load url from future %} +
    +{% for news in object_list %} +
  • {{ news.title }}
  • +{% endfor %} +