No title Revision 373164666138 (Wed Jun 02 2010 at 12:14) - Diff Link to this snippet: https://friendpaste.com/7QtUTWQIPK1wOip3EAIyqc Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172home.html{% extends "layout/base2.html" %}{% load generic_content %}{% load blog_extras %}{% block cont_actu %}{% get_latest_objects blog.entry 5 as latest_entry %}{% display_last_entry %}{% endblock cont_actu %}blog_extras.py# -*- coding: utf-8 -*-from django import templatefrom django.template import Library, Node, TemplateSyntaxErrorfrom django.conf import settingsfrom monsite.blog.models import Tag,Entryregister = template.Library()@register.inclusion_tag('blog/tag_list.html')def show_alltags(): allmytags = Tag.objects.order_by('name') return {'alltags': allmytags}@register.inclusion_tag('blog/archive_by_year.html')def archive_by_year(): year_list = Entry.objects.dates('pub_date','year', order='ASC') return {'year_list': year_list}@register.inclusion_tag('blog/archive_by_month.html')def archive_by_month(): month_list = Entry.objects.dates('pub_date','month', order='ASC') return {'month_list': month_list}def display_last_entry(context): """ Display latest posts, ``latest_posts`` var should be in the context. Usage:: {% get_latest_objects journal.Post 5 as latest_posts %} {% display_footer_posts %} This will use ``display_footer_posts.html`` template. """ return { 'latest_entry': context['latest_entry'] }register.inclusion_tag('blog/display_last_entry.html', takes_context=True)(display_last_entry)display_last_entry.html<h3>Derniers billets publiés</h3><ul>{% for entry in latest_posts %} <li><a href="{{ entry.get_absolute_url }}" title="Lire le billet intitulé {{ entry.title }}">{{ entry|safe }}</a></li>{% endfor %}</ul>