rix*_*rix 7 python django django-templates
我正在做以下事情:
{% for wrapping in wrappings %} //array of strings
<input type="radio" value="{{ wrapping[:-3] }}" etc
Run Code Online (Sandbox Code Playgroud)
我想输出包装中的所有字符串减去最后3个字母,但我收到了:
TemplateSyntaxError: Could not parse the remainder: '[:-3]' from 'wrapping[:-3].
知道什么是错的/如何做到这一点好吗?谢谢,
Jon*_*nts 19
你可以使用切片过滤器:
{{ wrapping|slice:":-3" }}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9223 次 |
| 最近记录: |