python - AttributeError:模块“django.db.models”没有属性“IntegerChoices”
问题描述
我有一个无法解决的问题,在启动服务器时,它给出了一个错误:
类 CritLevel (models.IntegerChoices): AttributeError: 模块 'django.db.models' 没有属性 'IntegerChoices'
我在模型中的代码:
import uuid
from common.models import CommonPermissionSet
from django.core.validators import MinValueValidator
from django.db import models
from django.utils.translation import gettext_lazy as _
from. import managers
class CritLevel (models.IntegerChoices):
LOW = 1, _ ('Low')
MEDIUM = 2, _ ('Medium')
HIGH = 3, _ ('High')
class TypeElHw (models.IntegerChoices):
EL = 1, _ ('Electrical Energy')
HW = 2, _ ('Heat energy')
class OrganizationType (models.IntegerChoices):
EPO = 1, _ ('EPO')
ESO = 2, _ ('ESO')
解决方案
推荐阅读
- r - 在 R markdown 中使用块外和文本内的回归输出
- azure - 无法使用 MQTT 和 ESP8266 订阅 Azure 设备孪生
- class - 如何使用 JavaFx 中的 GridPane 在一行中对齐四个按钮
- reactjs - 从状态设置值
- eclipse - 在 Eclipse 的树视图中更改项目符号的颜色
- javascript - 外部文件中的JSDoc,可能吗?如何?
- python - Google 联系人 API 引发 TypeError('Got an unexpected keyword argument "%s"' % name)
- sql - Sql 加入两个表并返回空选项卡作为不可用
- dart - 在 Dart (Not Flutter) 中更新变量后如何让 UI 自动更新?
- node.js - 在 NODEJS 中使用 passport-ci-oidc 库时间歇性地出现错误“状态不匹配”