teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2021/07/30 03:13

投稿

quickquip
quickquip

スコア11314

answer CHANGED
@@ -1,2 +1,10 @@
1
1
  [https://docs.djangoproject.com/ja/3.2/ref/templates/builtins/#std:templatetag-for](https://docs.djangoproject.com/ja/3.2/ref/templates/builtins/#std:templatetag-for)
2
- `forloop.counter0`じゃないでしょうか。
2
+ `forloop.counter0`じゃないでしょうか。
3
+
4
+ ----
5
+
6
+ そうでした。`[]`でのアクセスかできないんでした。
7
+ [https://stackoverflow.com/questions/4651172/reference-list-item-by-index-within-django-template#answer-29664945](https://stackoverflow.com/questions/4651172/reference-list-item-by-index-within-django-template#answer-29664945)
8
+ のようにカスタムフィルタを作成する方法があります。
9
+
10
+ Django的には、renderを呼び出す側でparamsで渡す時点でループで回したいデータが`zip`関数でまとられていることが想定されていると思います。