【发布时间】:2016-12-07 11:24:16
【问题描述】:
我有一个使用 django_tables2 填充的表,有两列:
tables.py
class SummaryTable(tables.Table):
update = CheckBoxColumnWithName(verbose_name = "Select",accessor="pk",
orderable=False)
class Meta:
model = Vehicle
fields = ('update', 'vehid')
# Add class="paleblue" to <table> tag
attrs = {'class':'paleblue'}
列更新和vehid。
我需要的是限制用户只选择一个复选框,如果他们选择另一个复选框,它会取消选择第一个并选择新的选择。
谁能建议如何做到这一点?
【问题讨论】:
-
什么是 CheckBoxColumnWithName?我在django-tables2.readthedocs.io/en/latest/pages/…的tables2 文档中看不到它
-
@nigel222 这是一个自定义的
CheckBoxColumn,允许标题 -
我猜你想要的是一个自定义列,它将生成一列单选按钮,或者一列链接到 JavaScript 的按钮,它将最新的选择复制到一个(可能隐藏) 输入框。不过,我不是自愿写的!
标签: python django checkbox django-tables2