{% if type == "Cryptography" %}
{% include 'Cryptography/_____.html' %}
{% elif type == "Password Cracking" %}
{% include 'PasswordCracking/_____.html' %}
{% endif %}在模板中,我希望包含一些包含1.html 2.html 3.html的HTML页面,这些页面位于C和PC目录中。我尝试过这样做,其中页面是我的参数变量。
{% if type == "Cryptography" %}
{% include 'cryptography/'{{page}}'html' %}
{% elif type == "Password Cracking" %}
{% include 'PasswordCracking/'{{page}}'.html' %}
{% endif %}视图中的
def lessons(request, foo, page):
return render(request, 'lessons.html', {'type': foo, 'page': page})注释:类型和页面是我的参数
发布于 2019-12-30 06:33:17
可以使用add筛选器连接字符串。
{% if type == "Cryptography" %}
{% include "cryptography/"|add:page|add:".html" %}
{% elif type == "Password Cracking" %}
{% include "PasswordCracking/"|add:page|add:".html" %}
{% endif %}https://stackoverflow.com/questions/59526540
复制相似问题