Model
model._meta.model_namemodel._meta.app_labelmodel._meta.get_field("字段")
--------book:list_filter=["state", "publish", "authors"] each field related information: Field string: "State" Field object : Book._meta.get_field ("State") field Association data: If---Choice Type field: Field object. choices If---foreignkey,manytomany: Field object. rel.to.objects.all () field information is encapsulated into a class: Class Filterfield (object): Def __init__ (self,filter_field_name,filter_field_obj): Self.fil Ter_field_name=filter_field_name Self.filter_field_obj=filter_field_obj def get_ Data (self): if Isinstance (Self.filter_field_obj,foreignkey) or isinstance (SELF.FILTER_FIELD_OBJ,MANYTOMANYF Ield): Return Self.filter_field_obj.rel.to.objects.all () elif Self.filter_field_obj.choi Ces:return self.filter_field_obj.choices Else:pass State=filterfield("state", State_obj)
_meta Partial usage