나는 다음과 같은 사전이 있습니다표시 사전 파일
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]
를 표시하려면 django 템플릿에서 {% if d.keys in x %}
을 호출합니까?
여기 장고 템플릿 [tag] (https://docs.djangoproject.com/en/2.0/howto/custom-template-tags/)이 필요합니다. 이 문제는 상당히 사소한 것입니다. – MCBama
그리고 당신의 컨텍스트에서'list_upper'를 정의하지 않은 이유가 무엇입니까? for 루프에서 템플릿에 미친 코딩을 할 필요는 없습니다. – MCBama