文章内容

2018/7/18 12:09:14,作 者: 黄兵

Block names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead

最近在使用python的时候,报如下错误:

jinja2.exceptions.TemplateSyntaxError: Block names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead.


出现这个问题的原因:

jinja2.exceptions.TemplateSyntaxError:Jinja中的块名称必须是有效的Python标识符,并且可能不包含连字符,而是使用下划线。

block中使用了连字符(中划线)。

出错代码如下所示:

<!-- BEGIN TOP NAVIGATION MENU -->
{% block top-menu %}
{{ super() }}
{% endblock %}
<!-- END TOP NAVIGATION MENU -->


解决方案:

修改top-menutop_menu

最户问题解决。


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - Block names in Jinja have to be valid Python identifiers and may not contain hyphens, use an underscore instead

分享到:

发表评论

评论列表