更新时间:2023-11-25 22:52:46
理想情况下,您要做的是创建一个模板获取的列表:
Ideally what you would do is create a list that the template gets as such:
l = [s.name for s in sections]
在模板中,使用:
{% if 'Social' in l %}
您正试图在模板中加入比预期更多的逻辑.模板应该尽量少用逻辑,而逻辑应该在填充模板的代码中.
You're trying to put more logic into a template than they are meant to have. Templates should use as little logic as possible, while the logic should be in the code that fills the template.