python - 显示已保存选定选项的单选按钮,带有 Python Bootstrap
问题描述
我对 Python Bootstrap 很陌生,我为特定字段entrepot.etage创建了一个带有单选按钮选项的 Python Bootstrap 表单 我想知道在保存的数据库记录中显示哪个选项被选中的最佳方法是什么?就像“选项 2”保存在我的记录中一样,我希望在您使用单选按钮进行编辑或查看时对其进行检查。
有我的 HTML 文件(只是重要的部分)
<form action="/entrepots/edit_entrepot" method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="col-lg-12">
<div class="form-group">
<div class="col-sm-4">
<label class="control-label">Étage : </label>
<div class="form-group">
<label class="radio-etage">
<input type="radio" name="etage" value="1">1
</label>
<label class="radio-etage">
<input type="radio" name="etage" value="2">2
</label>
</div>
</div>
<div class="form-group">
<input type="hidden" value="{{ entrepot.id }}" name="id">
<input type="submit" name="submit" class="btn btn-block btn-success" value="Modifier Entrepots">
</div>
</div>
</div>
</form>