django中choices字段获取对应字段值

``

class Area(models.Model):
    Area_Level = (
         (0, u'全国'),
         (1, u'省、直辖市'),
         (2, u'市、直辖市区'),
         (3, u'区、县等'),
    )
areaname = models.CharField(max_length=30,unique=True, verbose_name='区域名称')
code = models.CharField(max_length=20,blank=True, default="", verbose_name='区域代码')
parentid  = models.IntegerField(verbose_name='父级id', null=True)
level = models.IntegerField(choices=Area_Level,verbose_name='层级', null=True)

object.get_level_display()

你可能感兴趣的:(django中choices字段获取对应字段值)