【发布时间】:2022-01-17 07:32:22
【问题描述】:
我想在表单旁边而不是下面显示一个按钮:
看起来是这样的:
应该是这样的:
对应代码:
表格:
class TheForm(forms.Form):
var = forms.ChoiceField(choices = choices, label = "")
温度
late:
{% if TheForm %}
<form method = "post">
{% csrf_token %}
{% bootstrap_form TheForm %}
{% bootstrap_button button_type="submit" content="OK" %}
</form>
{% endif %}
编辑: 得到它的工作,但代码只适用于一个输入字段:
我想象它会是这样的:
但生成的代码看起来也很奇怪:
<form method="POST" action="/singleDevice">
<input type="hidden" name="csrfmiddlewaretoken" value="...">
<div class="row">
<div class="col-9">
<div class="col-12">
<select name="env" class="form-select" id="id_env">
<option value="0">A</option>
<option value="3">NB</option>
</select>
</div>
<div class="col-12">
<label class="visually-hidden" for="id_Number">directly enter a number</label>
<input type="text" name="Number" class="form-control" placeholder="directly enter a number" id="id_Number">
</div>
</div>
<div class="col-3">
<button class="btn btn-primary" type="submit">OK</button>
</div>
</div>
</form>
【问题讨论】:
标签: django django-forms django-templates bootstrap-5