Django模型,使用另一个对象的值作为choi

2024-05-16 11:29:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用另一个对象的值作为如下选择。因此,我将有一个预定义的维护类型列表,可以在impact字段中进行选择。当我试图创建这个模型时,我得到了一个错误

[root@network-tools infternal]# python manage.py makemigrations maintenance
SystemCheckError: System check identified some issues:

ERRORS:
maintenance.Maintenance.Impact: (fields.E004) 'choices' must be an iterable (e.g., a list or tuple).

模型配置

^{pr2}$

Tags: 对象py模型类型列表manage错误root