【发布时间】:2014-03-15 00:24:32
【问题描述】:
我在models.py中有课:
class Companies(models.Model):
id = models.AutoField(unique=True, primary_key=True, null=False, blank=False)
is_active = models.BooleanField(default=1, editable=False)
在 HTML 模板中有这个无线电组:
<fieldset>
<legend>Status</legend>
<input type="radio" name="is_active" value="">All</label>
<input type="radio" name="is_active" value="True" checked="1">Active</label>
<input type="radio" name="is_active" value="False">Not Active</label>
</fieldset>
我想使用 jquery 序列化()radiogroup 并发送到tastepie API 以从模型中获取过滤数据:
来自查询的 URL 将如下所示:
http://localhost:8000/api/view/company/list/?is_active=
结果将仅显示 is_active 字段中具有 False 值的行
如果我使用 ?is_active=1 结果将只有 True
如何从表中获取 True 和 False 行?
我可以更改输入中的“名称”属性,但所有输入中的名称必须相同才能保持分组。
【问题讨论】:
标签: django boolean filtering tastypie