Jinja2 模板超级函数未使用 django 呈现

Jinja2 template super functions not rendered with django

我有两个非常简单的模板,比如

index.html:

<html>
    <head>
    </head>
    <body>
        {% block content %}hello{% endblock %}
    </body>
</html>

和details.html

{% extends "index.html" %}
{% block content %}{{ super() }} world{% endblock %}

但是当我使用 details.html 渲染视图时出现此错误

Could not parse the remainder: '()' from 'super()'

我需要导入一些东西吗?

(在我使用 super() 函数之前模板会正确呈现)

Django 1.7 及更早版本本身不支持 Jinja。除非你做了一些使用Jinja的事情,否则你的模板应该是Django模板语言,你不能使用Jinja。

Django 1.8 将 support for multiple template engines 和对 Jinja2 的本地支持。

在 Django 模板语言中,您可以使用 {{ block.super }} 从父模板访问块的内容。