如果我的对象是 {(title: 'one', content: 'foo'), (title: 'two', content: 'bar')}
我该如何去获得'为'和'栏'到我的模板?我有一个对象列表,并希望返回一个属性与另一个属性
事情是这样的:
{% for content in content_list where content.title='one'}
{{ content.content }}
在 '富' 由此而来。
{% for content in content_list where content.title='two'}
{{ content.content }}
产生'酒吧'。
你为什么不使用,如果?? – Exprator
在模板上下文中添加两个列表会更快,更易于阅读。 –