1.进入到工程目录
from crm import models #crm代表app名称
复制代码
2.通过表名获取app名字
dir(models.CustomerInfo._meta)
models.CustomerInfo._meta.app_label #'crm'
复制代码
3.获取表名
models.CustomerInfo._meta.model
models.CustomerInfo._meta.model_name
复制代码
4.利用反射
models.CustomerInfo._meta.fields #获取model每一个字段(对象)
models.CustomerInfo._meta.get_field('statis') #取一个字段的对象
复制代码
5.获取choices
a = models.CustomerInfo._meta.get_field('statis')
a.choices
复制代码
6.反射
a = models.CustomerInfo.objects.last()
getattr(a,'get_statis_display')()
#已退学
复制代码