Nas*_*idi 3 forms django python-3.x
我有一个案例,我想使用单选按钮作为我的查询选项,这样我就可以根据所选的单选按钮获得正确的查询集.我无法找到一种方法来获取表单中选定的单选按钮值.关于使用表单类有很多信息.简单的html表单怎么样?形式的一部分是:
<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"/>
Run Code Online (Sandbox Code Playgroud)
这些单选按钮是另一个小部件的一部分,以帮助我获得正确的QuerySet.在视图中:
h_type = request.POST.get('h_type')
Run Code Online (Sandbox Code Playgroud)
这将返回一个非类型对象.如何获得所选单选按钮的值?
| 归档时间: |
|
| 查看次数: |
8774 次 |
| 最近记录: |