Template tag render method never called

14 views
Skip to first unread message

Kevin Tonon

unread,
Jun 27, 2007, 1:44:39 PM6/27/07
to Django users
Hi,

I'm using Django 0.91

More or less, this is what I'm doing:

appname/templatetags/app_extras.py:

from django.core.template import Library, Node
register = Library()

class MyNode(Node):
def __init__(self, foo):
self.foo = foo
print 'foo' * 100

def render(self, context):
print 'bar' * 100
return 'bar' * 100

@register.tag
def mytag(parser, token):
return MyNode(0)

In my template:
{% load app_extras %}
{% mytag %}

When I run this using the development server, 'foo' * 100 is printed,
but 'bar' * 100 is not. That is, it looks like render is never being
called? Is there anything obviously wrong with what I'm doing?

On another note, I tried stepping through the code with pdb, but it
was ignoring my breakpoints. I tried running the server with --
noreload too, but 0.91 doesn't seem to support that.

Any advice would be greatly appreciated, thanks.
Kevin

Kevin Tonon

unread,
Jun 27, 2007, 4:00:51 PM6/27/07
to Django users
I have determined the source of my problem. It was an inheriting
template defining a block and shadowing the parent block in which my
tag was called.
Reply all
Reply to author
Forward
0 new messages