Hi! I've got custom template tag 'set_title' and can't get it work because render() method isn't called during page render.
I use the tag in template 'traff/all_by_days.html': {% extends "traff/all_base.html" %} {% load traff_tags %} {% set_title "The title" %} ..... When I call render_to_response() Django creates NewTitleNode object but doesn't use it for rendering (I can see "in init" message but not "in render".) What I'm doing wrong? Here is my module with custom tag: #traff_tags.py from django import template register = template.Library() @register.tag() def set_title(parser, token): try: # split_contents() knows not to split quoted strings. tag_name, format_string = token.split_contents() except ValueError: raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents.split()[0] if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")): raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name return NewTitleNode(format_string[1:-1]) class NewTitleNode(template.Node): def __init__(self, format_string): self.format_string = format_string print "in init" def render(self, context): context['page_title'] = self.format_string print "in render" return '' --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---