Hi, I've been trying to get something together to see if I can get to grips with writing my own tempalte tags. In the end I came up with something like this (so far):
from myproject.shop.models import Product from django import template register = template.Library() def get_latest_products(parser, token): # Get list of products by date. latestProducts = Product.objects.all().order_by('pub_date')[:5] return latestProductsNode() class latestProductsNode(template.Node): def __init__(self): # Get list of products by date. self.latestProducts = Product.objects.all().order_by('pub_date')[:5] def render(self, context): return self.latestProducts register.tag('latest_products', get_latest_products) Something tells me this is not the way to go about what I want to do. All I want is a tag that outputs a list of the five most recent products. Anyone care to give me any pointers on this? Thanks, James --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---