1
我有一种情况,我想使用单选按钮作为我的查询选项,这样我就可以根据选定的单选按钮获取正确的查询集。 我找不到在表单中获取选定单选按钮值的方法。有很多关于使用表单类的信息。简单的html表单怎么样?形式的部分是:获取在Django视图中选定的单选按钮值
<label for="house-all-id">All</label>
<input type="radio" id="house-all-id" name="h-type" value="0"/>
<label for="house-orp-id">Just case one</label>
<input type="radio" id="house-orp-id" name="h-type" value="1"/>
<label for="house-inm-id">Just case two</label>
<input type="radio" id="house-inm-id" name="h-type" value="2"/>
这些无线电按钮的一部分从另一个部件,以帮助我得到正确的查询集。鉴于:
h_type = request.POST.get('h_type')
这将返回一个非类型的对象。我怎样才能获得所选单选按钮的价值?
OMG!只是一个错字!我试了2个小时才解决这个问题 –