#1 by lianfeng
hey, I'm here again: last problem now changed into this: 'KeyError: <class 'otree.forms.widgets.CheckboxInput'>' and here is my code: coop_project_reason = models.IntegerField( label='8.你参与小组合作项目的原因是什么?', choices=[ (1, '兴趣 & 社交扩展 & 技能学习'), (2, '奖金激励 & 推免资格'), (3, '课程要求') ], widget=widgets.CheckboxInput, ) but i don't think there is any mistake, how would last problem happened? thanks for all answers
#2
by
BonnEconLab
I don’t think that there is a CheckboxInput widget in oTree. See https://otree.readthedocs.io/en/latest/forms.html#raw-html-widgets for implementing checkboxes.
#3 by lianfeng
well, i got the instruction about widgets from the code: from otree.forms import widgets dir(widgets) maybe something went wrong and i got the answer : ['BaseWidget', 'CURRENCY_SYMBOLS', 'CheckboxInput', 'CurrencyWidget', 'Decimal', 'FloatWidget', 'IntegerWidget', 'Markup', 'RadioOption', 'RadioSelect', 'RadioSelectHorizontal', 'Select', 'SelectOption', 'TextArea', 'TextInput', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'core_gettext', 'escape', 'html_params', 'settings', 'text_type'] i will try your advice. thanks for that!
#4
by
Chris_oTree
For the list of widgets, you should consult the documentation. dir() just inspects oTree’s internal source code and produces miscellaneous things that are internal, deprecated, experimental, and prone to breakage.
#5 by lianfeng
got it and thanks