Django 两个模板彼此内部 无法解析其余部分



我在代码的这一部分Could not parse the remainder: '"' from '"'错误:

{% include 'test.html' with pic_url="{% static 'picture.jpg' %}" %}

是否可以在 Django 模板中编写这样的东西?

您不能像这样组合模板标签。

相反,您可以做的是将一个模板标签的结果分配给变量。并非所有模板标签都可能,但可以使用static标签:

{% static 'blog-single.html' as some_variable %}
{% include 'test.html' with post_url=some_variable %}