Django模板中{%include''with%}

时间:2018-05-10 19:32:53

标签: python django

我正在尝试以特定方式使用下面的代码。

{% include 'your_template_here' with keyword='your_value_here' %}

我想做的是将我的论据store_list传递给your_value_here作为参数keyword的论据。也就是说,它应该如下所示:

{% include 'your_template_here' with keyword={{ store_list }} %}

但是,它有语法错误。是否不允许在{%include''with =''%}中传递查询集?

1 个答案:

答案 0 :(得分:0)

我想传递一个数组

{% include '/blocks/block-products-carousel.html' with
        groups= [
            {title: 'All', active: true},
            {title: 'Power Tools', active: false},
            {title: 'Hand Tools', active: false},
            {title: 'Plumbing', active: false},
        ],