我有一个简单的选择领域:
class seguimentTutorialForm(forms.Form):
pregunta_select = forms.ChoiceField( )
def __init__(self, *args, **kwargs):
self.pregunta = kwargs.pop( pregunta , None)
super(seguimentTutorialForm,self).__init__(*args,**kwargs)
self.fields[ pregunta_select ].widget.choices=
[( ,u ---Tria--- )] +
[ (x.strip(),x.strip(), ) for x
in self.pregunta.possibles_respostes.split( | )]
我在POST数据上发现这一验证错误:
Select a Valid Choice NO is not one of the available choices
这是生成的html表格:
<tr>
<td class="label_tag">
<label for="id_6_3-pregunta_select">blah blah?</label>:</td>
<td class="tria_tag" class="conte_errors" >
<select name="6_3-pregunta_select" id="id_6_3-pregunta_select">
<option value="">---Tria---</option>
<option value="NO" selected="selected">NO</option>
<option value="Sí, AO">Sí, AO</option>
<option value="Sí, AA">Sí, AA</option>
<option value="Sí, PS">Sí, PS</option>
<option value="Sí, UEE">Sí, UEE</option>
</select>
<br/><span class="help_text">( Tipus alumne )</span>
<ul class="errorlist"><li>Select a Valid Choice NO is not one of the available choices.</li></ul>
</td>
</tr>
解决这一问题的一些想法?