如何在我的 models.py 文件中使用 choice_fields 以及如何在我的输出中表示它们?

How can I use choice_fields in my models.py file and how to represent them in my output?

我试图在名为 'action' 的模型中包含一个属性,以显示特定待办事项的操作状态。为此,我尝试创建这些文件,但它没有按照我的要求工作。

我希望有下拉菜单或复选框,但还没有。

您可以使用字符字段创建

class Model:
  choices = (
    (a, a),
     (b,b)
  )
 choice = models.charField(choices=choices )