我正在尝试在Django中设置一个选择字段,但我认为这不是Django问题。 choices字段需要一个可迭代的对象(例如列表或元组)作为此字段的选择项。
这是我的代码:
self.fields['question_' + question.id] = forms.ChoiceField(
label=question.label,
help_text=question.description,
required=question.answer_set.required,
choices=[("fe", "a feat"), ("faaa", "sfwerwer")])
由于某些原因,我总是得到以下错误:
TypeError - cannot concatenate 'str' and 'long' objects
最后一行始终被突出显示。
我不是在尝试连接任何内容。几乎无论我将列表更改为“choices”参数的什么内容,都会出现此错误。
发生了什么?