【发布时间】:2023-03-27 16:25:01
【问题描述】:
我尝试在 Django 中发布输入按钮的值,但我不能 这是我的模板
<form id="ReviewRateForm" method="post" action="/review/post/rate/">
<input type="button" hint="V1" title="V" value="1" id="radio{{ forloop.counter }}-1" type="button" name="qid[{{forloop.counter}}]"></input>
<input type="button" hint="V1" title="V" value="2" id="radio{{ forloop.counter }}-1" type="button" name="qid[{{forloop.counter}}]"></input>
<input type="button" hint="V1" title="V" value="1" id="radio{{ forloop.counter }}-1" type="button" name="qid[{{forloop.counter}}]"></input>
</form>
但是,当我调试它时,我无法在我的视图中达到该输入按钮的值。
有什么问题或我该如何克服?
【问题讨论】:
-
您如何尝试访问视图中的值?您是否尝试访问
request.POST? -
... 而且,您为什么在
for块之外使用{{ forloop.counter }}?如果你确实有一个for块来包装粘贴的代码,你最终会得到所有 3 个输入都具有相同的name和id。你到底想做什么? -
@Shawn - 我同意。我不确定 o.p.正在尝试在这里做。
-
为什么不根据您要解决的问题,而不是根据如何使您的实现(永远不会很好地工作)工作来重新发布这个问题。跨度>
-
@Jordan 我一定会这样做的。对不起,伙计们,我在写那篇文章时牙痛得很厉害,现在我发现它的解释不好。对不起..
标签: django templates post button input