Har*_*rry 2 django many-to-many django-templates
这是我在forloop中的模板标记
{{ product.feature_set.all.1.value }}
Run Code Online (Sandbox Code Playgroud)
我想将数字1更改为forloop.counter.这是真的吗?
喜欢:
{{
product.feature_set.all.forloop.counter.value
}}
Run Code Online (Sandbox Code Playgroud)
它不是那样的,但是有办法做到这一点吗?
这没有意义.您应该遍历查询集本身.
{% for feature in product.feature_set.all %}
{{ feature }}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6486 次 |
| 最近记录: |