我试图通过仅使用请求而不是实际的 django 表单来获取表单的输入(我不需要将此数据存储在数据库中。)所以我尝试使用方法,但到目前为止我还没有request.GET.get()运气它。我很确定我的 HTML 有问题,但我可能是错的。这是我的观点.py
if request.method == "GET":
lineGraphInp=request.GET.getlist('lineGraphInp')
lineTableInp=request.GET.get('lineTableInp')
print(lineGraphInp)
print(lineTableInp)
另外,这是我的表格
<form method="GET">
<h3>Choose: </h3>
<select class="custom-select" name="lineTableInp">
<option value="myPosition">My Position</option>
<option value="myCompetitors">My Competitors</option>
<option value="top100">Top 100</option>
<option value="bottom100">Bottom 100</option>
</select>
</form>
和
<form method="GET">
<h3>Choose: </h3>
<div style="margin-left:15px;">
<div class="form-check form-check-inline">
<input name="lineGraphInp" class="form-check-input" type="checkbox" value="myPosition">
<label class="form-check-label" for="inlineCheckbox1">My Position</label>
</div>
<div class="form-check form-check-inline">
<input name="lineGraphInp" class="form-check-input" type="checkbox" value="myCompetitors" >
<label class="form-check-label" for="inlineCheckbox2">My Competitors</label>
</div>
<div class="form-check form-check-inline">
<input name="lineGraphInp" class="form-check-input" type="checkbox" value="top100">
<label class="form-check-label" for="inlineCheckbox3">Top 100</label>
</div>
<div class="form-check form-check-inline">
<input name="lineGraphInp" class="form-check-input" type="checkbox" value="bottom100">
<label class="form-check-label" for="inlineCheckbox3">Bottom 100</label>
</div>
</div>
</form>
慕姐8265434
相关分类