python: cannot concatenate 'str' and 'long' objects

前端 未结 5 1914
失恋的感觉
失恋的感觉 2020-12-11 14:34

I\'m trying to set up a choice field in django, but I don\'t think this is a django issue. The choices field takes an iterable (e.g., a list or tuple) of 2-tuples to use as

5条回答
  •  孤街浪徒
    2020-12-11 15:10

    This is a problem with doing too many things in one line - the error messages become slightly less helpful. Had you written it as below the problem would be much easier to find

    question_id = 'question_' + question.id
    self.fields[question_id] = forms.ChoiceField(
                    label=question.label,
                    help_text=question.description,
                    required=question.answer_set.required,
                    choices=[("fe", "a feat"), ("faaa", "sfwerwer")])
    

提交回复
热议问题