I'm steadily working through the excellent custom template tag tutorial:- http://www.b-list.org/weblog/2006/06/07/django-tips-write-better-template-tags
I've got the following code to create a template tag. However, I'm unclear as to what I need to put into my actual template. The author states, that based on the code below, I would need to add {% get_latest_polls 3 %} to the template, where 3 is a variable. However, while this not not create any errors, it is also not returning the latest 3 Polls. What else do I need to add? MerMer from django import template from mysite.polls.models import Poll, Choice class LatestPollsNode(template.Node): def __init__(self,num): self.num = num def render(self, context): context['polls'] = Poll.objects.all()[:self.num] return '' def get_latest_polls(parser, token): bits = token.contents.split() if len(bits) !=2: raise TemplateSyntaxError, "get latest_latest_polls tag take exactly one arguement" return LatestPollsNode(bits[1]) get_latest_polls = register.tag(get_latest_polls) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---