state_template = """
<select id="state_value">
<option{% if record.action_state = 'Planned' %} selected {% endif %}>Planned
<option{% if record.action_state = 'In_Progress' %} selected {% endif %}>In Progress
<option{% if record.action_state = 'Abandoned' %} selected {% endif %}>Abandoned
<option{% if record.action_state = 'Completed' %} selected {% endif %}>Completed
</select>
"""
class PlannedActionTable(tables.Table):
action_state = tables.TemplateColumn(state_template, verbose_name="State")
我需要能够在选择或更改下拉列表时进行数据库更改。有没有办法做到这一点?我试图创建一个表单类,但我不确定如何将它添加到TemplateColumn。