如何检查django模板中的条件部分部分
我想在循环运行时在模板第一轮中添加简单的CSS类。 {{forloop.counter}}每次显示循环计数。因此,我想做这样的事情{%forloop.counter == 1%}显示{%endif%}。但是它显示出如下:
无法分析其余部分:'== 1'从'forloop.counter == 1'
如何做?有解决方案吗?
I want add simple css class in the template first round of loop when for loop runs. {{forloop.counter}} shows count of for loops each time. so I want to do something like this {% if forloop.counter==1 %} show {% endif %}. but it shows error as below:
Could not parse the remainder: '==1' from 'forloop.counter==1'
How to do it? any solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您会忘记同等标志周围的空间:
You're forgetting about the spaces around the equal signs: