我有一个由 2 个 ChoiceField 和一个 CharField 组成的表单。The second ChoiceField is populated via ajax when an item of the first one is selected.
填充它的模板如下:
{% for a in assets %}
<option value="{{ a.asset_id }}">{{ a.asset_name }}_{{ a.asset_description }}</option>
{% endfor %}
当我尝试提交表单时,出现以下错误:
Select a valid choice. 20 is not one of the available choices.
指向第二个ChoiceField,20对应于选中项的{{a.asset_id}}。
我在其他论坛上看到了这个错误,但它几乎总是由于 multipleChoiceField 这不是我关心的。
我究竟做错了什么 ?