如何读取django模板中单选按钮的状态(已选中或未选中)

时间:2016-08-26 08:57:41

标签: python django templates

如何读取django模板中单选按钮的状态(已选中或未选中)。请注意,我想读取模板本身的状态,以便我可以根据使用单选按钮选择的用户显示模板的剩余内容。 模板row_list的上下文是这样的:

               col1     col2
  row1        "001"   "XML"
  row2        "002"   "HTML"
  row3        "003"   "DHTML"

     {% for a in row_list %}
      <p>
         {% if forloop.counter < 2 %}
          <input type="radio" name="items" id="choice" value= {{a.col1}} checked />
         {% else %}
           <input type="radio" name="items" id="choice" value ={{a.col1}}   />
        {% endif%}
       {{a.col2}}
    </p>
  {% endfor %}


      {% for r in row_list %}
           {%ifequal r.col1 rb_status %} <!--rb_status may be euqal to"001"/"002"/"003-->
             Subject: <input type="text" name="S_name" value= {{r.col2}}> <br>
          {%endifequal%}  
      {%endfor%} 

0 个答案:

没有答案
相关问题