当前位置 : 主页 > 手机开发 > ROM >

CRM项目实战-kingadmin model obj list 页面开发

来源:互联网 收集:自由互联 发布时间:2021-06-10
from kingadmin.admin_base import BaseKingAdmin class AdminSite(object): def __init__ (self): self.enabled_admins = {} def register(self,model_class,admin_class= None): """ 注册admin表 """ # print("register",model_class,admin_class) app_n
分享图片
from kingadmin.admin_base import BaseKingAdmin

class AdminSite(object):
    def __init__(self):
        self.enabled_admins = {}



    def register(self,model_class,admin_class=None):
        """注册admin表"""

        #print("register",model_class,admin_class)
        app_name = model_class._meta.app_label
        model_name = model_class._meta.model_name
        if not admin_class: #为了避免多个model共享同一个BaseKingAdmin内存对象
            admin_class = BaseKingAdmin()
        else:
            admin_class = admin_class()

        admin_class.model = model_class #把model_class赋值给了admin_class

        if app_name not in self.enabled_admins:
            self.enabled_admins[app_name] = {}
        self.enabled_admins[app_name][model_name] = admin_class



site = AdminSite()
sites.py

分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片分享图片

网友评论