首页 > 解决方案 > 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')

标签: pythondjango-models

解决方案


推荐阅读