def __init__(self, task, *args, **kwargs):
super(ChoiceAnswerForm, self).__init__(*args, **kwargs)
if task:
qs = task.choices
widget = forms.RadioSelect
empty_label = None
count = task.no_of_choices
if count > settings.TASK_CHOICE_SELECT_CUTOFF:
widget = forms.Select
empty_label = BLANK_CHOICE_DASH[0][1]
self.fields['answer'] = forms.ModelChoiceField(queryset=qs,
widget=widget,
empty_label=empty_label)
评论列表
文章目录