바뀜

둘러보기로 가기 검색하러 가기
385 바이트 추가됨 ,  2021년 6월 22일 (화) 12:47
17번째 줄: 17번째 줄:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== 탬플릿에서 출력 ===
+
== 탬플릿에서 사용 ==
 +
<syntaxhighlight lang="html+django">
 +
<select class='알아서' data-title="제목" data-style="알아서" data-menu-style="알아서">
 +
    {% for x,y in form.fields.선택속성.choices %}
 +
      <option value="{{ x }}"{% if form.fields.gender.value == x %} selected{% endif %}>{{ y }}</option>
 +
    {% endfor %}
 +
    </select>
 +
</syntaxhighlight>
 +
 
 +
=== 탬플릿에서 선택값 출력 ===
 
<nowiki>{{모델.속성}}</nowiki> 이 형태로 쓰면 DB에 기록된 형태의 데이터를 보여주고,
 
<nowiki>{{모델.속성}}</nowiki> 이 형태로 쓰면 DB에 기록된 형태의 데이터를 보여주고,
    
<nowiki>{{모델.get_속성명_display}}</nowiki>로 쓰면 사용자에게 보여지는 형태의 데이터를 보여준다.
 
<nowiki>{{모델.get_속성명_display}}</nowiki>로 쓰면 사용자에게 보여지는 형태의 데이터를 보여준다.
 
[[분류:장고 모델]]
 
[[분류:장고 모델]]

둘러보기 메뉴