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

前端 未结 5 1907
失恋的感觉
失恋的感觉 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条回答
  •  -上瘾入骨i
    2020-12-11 15:22

    self.fields['question_' + question.id]
    

    That looks like the problem. Try

    "question_%f"%question.id
    

    or

    "question_"+ str(question.id)
    

提交回复
热议问题