私は、次の辞書を持っている:表示辞書ファイル
d = {'21': 'test1', '11': 'test2'}
{% with '18 17 16 15 14 13 12 11 21 22 23 24 25 26 27 28' as list_upper %}
{% for x in list_upper.split %}
{% if x in dental_position %}
<input type="text" placeholder = "{{ x }}" class="form-control" name="tooth[]" value="{{display dict.value here}}">
{% else %}<input type="text" placeholder = "{{ x }}" class="form-control" name="tooth[]">
{% endif%}
{% endfor %}
d[key]
からの値が
どのようlist_upper
に発見されたとき、私は、入力されたテキスト値の属性の内部d[value]
を表示したいです私は{% if d.keys in x %}
をdjangoテンプレートと呼んでいますか?
ここではdjangoテンプレート[タグ](https://docs.djangoproject.com/en/2.0/howto/custom-template-tags/)が必要です。この問題はかなり簡単になります。 – MCBama
あなたのコンテキストで 'list_upper'を定義しなかった理由はありますか?あなたはあなたのforループのためにやっているあなたのテンプレートで狂ったコーディングする必要はありません。 – MCBama