2

model一些琐碎知识点

(obj)model对象的._meta可以获取很多信息

get_column_display 可以获取 choice的中文

_meta.get_field 可以得到字段对象

_meta.get_fields()__dict__["name"]可以得到字段对象

model里面定义了 str

返回的queryset对象就是这样子的

<QuerySet [<Customer: 陈融化>, <Customer: 赵凡>, <Customer: 皱皮>]>

for i in admin_obj.querysets:
    print(type(i))
    
    
<class 'crm.models.Customer'>
<class 'crm.models.Customer'>
<class 'crm.models.Customer'> 


print(i)   

陈融化
赵凡
皱皮
原文地址:https://www.cnblogs.com/wspblog/p/6647465.html