Python django.apps.apps 模块,get_containing_app_config() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用django.apps.apps.get_containing_app_config()

项目:django-clubhouse    作者:chazmead    | 项目源码 | 文件源码
def contribute_to_class(self, cls, name):
        setattr(cls, name, self)
        self.original_attrs = {}
        if self.meta:
            meta_attrs = self.meta.__dict__.copy()
            for name in self.meta.__dict__:
                if name.startswith('_'):
                    del meta_attrs[name]
            for attr_name in DEFAULT_NAMES:
                if attr_name in meta_attrs:
                    setattr(self,attr_name,meta_attrs.pop(attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)
                elif hasattr(self.meta, attr_name):
                    setattr(self, attr_name, getattr(self.meta, attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)

        del self.meta

        self.object_name = self.base_block.__name__

        if self.app_label is None:
            module = self.base_block.__module__
            self.app_config = apps.get_containing_app_config(module)
            self.app_label = self.app_config.label
项目:django-admin-reports    作者:simplyopen-it    | 项目源码 | 文件源码
def get_urls(self):
        urlpatterns = []

        for report in self._registry:
            app_name = apps.get_containing_app_config(report.__module__).name
            urlpatterns.append(
                url(r"^{0}/{1}/$".format(app_name.replace(".", "_"), report.__name__.lower()),
                    ReportView.as_view(report_class=report),
                    name=camel_re.sub(r'\1_\2', report.__name__).lower()
                ))
        return urlpatterns
项目:a4-meinberlin    作者:liqd    | 项目源码 | 文件源码
def register(self, description, cls):
        app_config = django_apps.get_containing_app_config(cls.__module__)
        app_label = app_config.label
        app_exports = self._registry.get(app_label, [])
        app_exports.append((description, cls))
        self._registry[app_label] = sorted(app_exports, key=lambda e: e[1])
项目:dsmr-reader    作者:dennissiemensma    | 项目源码 | 文件源码
def app(self):
        return apps.get_containing_app_config(type(self).__module__).name
项目:dsmr-reader    作者:dennissiemensma    | 项目源码 | 文件源码
def app(self):
        return apps.get_containing_app_config(type(self).__module__).name
项目:dsmr-reader    作者:dennissiemensma    | 项目源码 | 文件源码
def app(self):
        return apps.get_containing_app_config(type(self).__module__).name