在我的django模板中,我需要基于相同的压缩列表添加两个循环。不幸的是,似乎只执行了第一个循环。
views.py中包含以下代码:
remove
我的模板:
{"name":"xx","description":"aaabbb"}
在渲染时,第二个for循环不会迭代。 呈现的html:
// This is in my component. Just illustrating here what it is set to.
jsonHeaderOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };
public addCall(dataObject: any) {
let body = JSON.stringify(dataObject);
return this.httpClient
.post(this.uri, body, this.jsonHeaderOptions);
};
为什么会这样?
答案 0 :(得分:1)
在Python 3中,zip
返回一个生成器:一旦迭代,它就被耗尽。您应该先将其转换为列表:
weekzip = list(zip(weekdays, weekdaynum))