Django自定义模板标记问题

Django自定义模板标记问题,django,Django,这是我为“box”编写的python代码: register = Library() class KeyNode(Node): def __init__(self, _node): self._node = _node, def render(self, context): try: #content = "this works!" content = self._node.render(con

这是我为“box”编写的python代码:

register = Library()

class KeyNode(Node):
    def __init__(self,  _node):
        self._node = _node,

    def render(self, context):
        try:
            #content = "this works!"
            content = self._node.render(context)
            return content
        except:
            bilogger.exception('KeyNode')
            return ''

@register.tag('box')
def wrapper(parser, token):
    try:
        #fn, _option = token.split_contents()
        node = parser.parse(('endbox',))
        parser.delete_first_token() 
    except ValueError:
        raise TemplateSyntaxError("INVALID FORMAT PROVIDED FOR BOX")
    return KeyNode(node)
self._node.render(上下文)是一个空字符串,不会返回任何内容。但是,content=“this works!”,有效


这里怎么了?

self.\u node=\u node,
-也许这是你的错误
a=1,
=
(1,)
render()
中,上下文的值是多少?
节点的值是多少?(举个例子就可以了)还有一个问题。。。。发生了什么事?什么也不退?您可能希望删除try catch以了解发生了哪些异常。@srusskih,您说得对!元组是问题的根源