Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在{%include%}标记django中包含我的参数?_Python_Django_Django Templates_Django Views - Fatal编程技术网

Python 如何在{%include%}标记django中包含我的参数?

Python 如何在{%include%}标记django中包含我的参数?,python,django,django-templates,django-views,Python,Django,Django Templates,Django Views,在一个模板中,我想包含一些包含1.HTML2.HTML3.HTML的HTML页面,它们位于C和PC目录中。我试过这样做,页面是我的参数变量 {% if type == "Cryptography" %} {% include 'Cryptography/_____.html' %} {% elif type == "Password Cracking" %} {% include 'PasswordCracking/_____.html' %}

在一个模板中,我想包含一些包含1.HTML2.HTML3.HTML的HTML页面,它们位于C和PC目录中。我试过这样做,页面是我的参数变量

    {% if type == "Cryptography" %}
        {% include 'Cryptography/_____.html' %}
    {% elif type == "Password Cracking" %}
        {% include 'PasswordCracking/_____.html' %}
    {% endif %}
对此的看法

    {% if type == "Cryptography" %}
        {% include 'cryptography/'{{page}}'html' %}
    {% elif type == "Password Cracking" %}
        {% include 'PasswordCracking/'{{page}}'.html' %}
    {% endif %}
注意:type和page是我的参数

您可以使用筛选器连接字符串

def lessons(request, foo, page):
    return render(request, 'lessons.html', {'type': foo, 'page': page})

谢谢,老兄,你帮我节省了时间。但是你忘记了“.in”.html”
{% if type == "Cryptography" %}
    {% include "cryptography/"|add:page|add:".html" %}
{% elif type == "Password Cracking" %}
    {% include "PasswordCracking/"|add:page|add:".html" %}
{% endif %}