I created a special tag that I want to use, but Django does not seem to be able to find it. My templatetags directory is configured as follows:

pygmentize.py
from pygments import highlight from pygments.lexers import get_lexer_by_name from django import template from pygments.formatters.other import NullFormatter register = template.Library() @register.tag(name='code') def do_code(parser,token): code = token.split_contents()[-1] nodelist = parser.parse(('endcode',)) parser.delete_first_token() return CodeNode(code,nodelist) class CodeNode(template.Node): def __init__(self,lang,code): self.lang = lang self.nodelist = code def render(self,context): code = self.nodelist.render(context) lexer = get_lexer_by_name('python') return highlight(code,lexer,NullFormatter())
I am trying to use this tag to render code in gameprofile.html .
gameprofile.html
(% load pygmentize %} {% block content %} <title>{% block title %} | {{ game.title }}{% endblock %}</title> <div id="gamecodecontainer"> {% code %} {{game.code}} {% endcode %} </div> {% endblock content %}
When I go to gameprofile.html , I get the error message:
Invalid block tag on line 23: "code", expected "end block". Did you forget to register or download this tag?
source share