0
我知道Django Dev版本將使this addition更容易,但是有什麼方法可以自定義當前版本的django中單選按鈕的選項字段嗎?評論版本是我期待做的。問題是,當表單無效時,表單會在沒有輸入任何原始條目的情況下重新加載。Django 1.3.1中的自定義選擇標籤和顯示
<div class="category box">
<p class="question">Category:</p>
{{ form.category.errors }}
{{ form.category }}
{% comment %}
<ul>
<li><label for="id_category_0"><input type="radio" id="id_category_0" value="E" name="category"><img src="{{ MEDIA_URL }}images/icons/eating.png"><br />Eating</label></li>
<li><label for="id_category_1"><input type="radio" id="id_category_1" value="D" name="category"><img src="{{ MEDIA_URL }}images/icons/drinking.png"><br />Drinking</label></li>
<li><label for="id_category_2"><input type="radio" id="id_category_2" value="S" name="category"><img src="{{ MEDIA_URL }}images/icons/sleeping.png"><br />Sleeping</label></li>
<li><label for="id_category_3"><input type="radio" id="id_category_3" value="P" name="category"><img src="{{ MEDIA_URL }}images/icons/exploring.png"><br />Exploring</label></li>
<li><label for="id_category_4"><input type="radio" id="id_category_4" value="O" name="category"><img src="{{ MEDIA_URL }}images/icons/other.png"><br />Other</label></li>
</ul>
{% endcomment %}
</div>
<div class="rating box">
<p class="question">How would you rate it??</p>
{{ form.rating.errors }}
{{ form.rating }}
{% comment %}
<ul>
<li><label for="id_rating_0"><input type="radio" id="id_rating_0" value="1" name="rating"><span class="glyph" style="color: lightgreen;">j</span> Must Do</label></li>
<li><label for="id_rating_1"><input type="radio" id="id_rating_1" value="2" name="rating"><span class="glyph" style="color: lightblue;">l</span> Do</label></li>
<li><label for="id_rating_2"><input type="radio" id="id_rating_2" value="3" name="rating"><span class="glyph">L</span> Miss</label></li>
</ul>
{% endcomment %}
</div>