当前位置: 首页>>代码示例>>Python>>正文


Python apps.all_models方法代码示例

本文整理汇总了Python中django.apps.apps.all_models方法的典型用法代码示例。如果您正苦于以下问题:Python apps.all_models方法的具体用法?Python apps.all_models怎么用?Python apps.all_models使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.apps.apps的用法示例。


在下文中一共展示了apps.all_models方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def delete(self, **kwargs):
        # first drop the table, we have to do this first, else
        # django will complain about no content type existing
        Model = apps.get_model("django_models_from_csv", self.name)
        ModelSchemaEditor().drop_table(Model)

        # then remove django app and content-types/permissions
        app_config = apps.get_app_config("django_models_from_csv")
        wipe_models_and_permissions(app_config, self.name)

        # finally kill the row
        super().delete(**kwargs)

        # delete it from the django app registry
        try:
            del apps.all_models["django_models_from_csv"][self.name]
        except KeyError as err:
            raise LookupError("'{}' not found.".format(self.name))

        # Unregister the model from the admin, before we wipe it out
        try:
            admin.site.unregister(Model)
        except admin.sites.NotRegistered:
            pass 
开发者ID:propublica,项目名称:django-collaborative,代码行数:26,代码来源:models.py

示例2: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def tearDown(self):
        # Taken from IsolatedModelsTestCase in
        # django/tests/invalid_models_tests/base.py
        from django.apps import apps

        apps.app_configs["tests"].models = self._old_models
        apps.all_models["tests"] = self._old_models
        apps.clear_cache() 
开发者ID:MarkusH,项目名称:django-osm-field,代码行数:10,代码来源:test_fields.py

示例3: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def tearDown(self):
        del apps.all_models['djangoseo']['dog'] 
开发者ID:whyflyru,项目名称:django-seo,代码行数:4,代码来源:tests.py

示例4: test_PG_EXTRA_SEARCH_PATHS

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def test_PG_EXTRA_SEARCH_PATHS(self):
        del apps.all_models['django_tenants']
        c = connection.cursor()
        c.execute('DROP SCHEMA {0} CASCADE; CREATE SCHEMA {0};'.format(
            get_public_schema_name()
        ))
        apps.set_installed_apps(['customers', 'django_tenants']) 
开发者ID:django-tenants,项目名称:django-tenants,代码行数:9,代码来源:test_settings.py

示例5: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def tearDown(self):
        # unregister InvalidStreamModel from the overall model registry
        # so that it doesn't break tests elsewhere
        for package in ('wagtailcore', 'wagtail.core.tests'):
            try:
                del apps.all_models[package]['invalidstreammodel']
            except KeyError:
                pass
        apps.clear_cache() 
开发者ID:wagtail,项目名称:wagtail,代码行数:11,代码来源:test_streamfield.py

示例6: create_models

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def create_models():
    """
    Build & register models from the DynamicModel descriptions found
    in our database.
    """
    for dynmodel in DynamicModel.objects.all():
        model_name = dynmodel.name
        _model = construct_model(dynmodel)
        if not _model:
            logger.error("No model was created for: %s" % model_name)
            continue

        these_models = apps.all_models["django_models_from_csv"]
        these_models[model_name] = _model 
开发者ID:propublica,项目名称:django-collaborative,代码行数:16,代码来源:models.py

示例7: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def tearDown(self):
        apps.app_configs['migrations'].models = self._old_models
        apps.all_models['migrations'] = self._old_models
        apps.clear_cache()
        super(MakeMigrationsTests, self).tearDown() 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:7,代码来源:test_commands.py

示例8: is_registered

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def is_registered(self, model_name):
        return model_name.lower() in apps.all_models[self.app_label] 
开发者ID:rvinzent,项目名称:django-dynamic-models,代码行数:4,代码来源:utils.py

示例9: unregister_model

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def unregister_model(self, model_name):
        try:
            del apps.all_models[self.app_label][model_name.lower()]
        except KeyError as err:
            raise LookupError("'{}' not found.".format(model_name)) from err 
开发者ID:rvinzent,项目名称:django-dynamic-models,代码行数:7,代码来源:utils.py

示例10: cleanup_registry

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def cleanup_registry():
    """
    The app registry bleeds between tests. This fixture removes all dynamically
    declared models after each test.
    """
    try:
        yield
    finally:
        app_config = apps.get_app_config(TEST_APP_LABEL)
        registered_models = app_config.get_models()
        apps.all_models[TEST_APP_LABEL].clear()
        apps.register_model(TEST_APP_LABEL, ModelSchema)
        apps.register_model(TEST_APP_LABEL, FieldSchema) 
开发者ID:rvinzent,项目名称:django-dynamic-models,代码行数:15,代码来源:conftest.py

示例11: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def tearDown(self):
        apps.app_configs['migrations'].models = self._old_models
        apps.all_models['migrations'] = self._old_models
        apps.clear_cache()
        super().tearDown() 
开发者ID:nesdis,项目名称:djongo,代码行数:7,代码来源:test_commands.py

示例12: test_egg1

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def test_egg1(self):
        """Models module can be loaded from an app in an egg"""
        egg_name = '%s/modelapp.egg' % self.egg_dir
        with extend_sys_path(egg_name):
            with self.settings(INSTALLED_APPS=['app_with_models']):
                models_module = apps.get_app_config('app_with_models').models_module
                self.assertIsNotNone(models_module)
        del apps.all_models['app_with_models'] 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:tests.py

示例13: test_egg2

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def test_egg2(self):
        """Loading an app from an egg that has no models returns no models (and no error)"""
        egg_name = '%s/nomodelapp.egg' % self.egg_dir
        with extend_sys_path(egg_name):
            with self.settings(INSTALLED_APPS=['app_no_models']):
                models_module = apps.get_app_config('app_no_models').models_module
                self.assertIsNone(models_module)
        del apps.all_models['app_no_models'] 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:tests.py

示例14: test_egg3

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def test_egg3(self):
        """Models module can be loaded from an app located under an egg's top-level package"""
        egg_name = '%s/omelet.egg' % self.egg_dir
        with extend_sys_path(egg_name):
            with self.settings(INSTALLED_APPS=['omelet.app_with_models']):
                models_module = apps.get_app_config('app_with_models').models_module
                self.assertIsNotNone(models_module)
        del apps.all_models['app_with_models'] 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:tests.py

示例15: test_egg4

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import all_models [as 别名]
def test_egg4(self):
        """Loading an app with no models from under the top-level egg package generates no error"""
        egg_name = '%s/omelet.egg' % self.egg_dir
        with extend_sys_path(egg_name):
            with self.settings(INSTALLED_APPS=['omelet.app_no_models']):
                models_module = apps.get_app_config('app_no_models').models_module
                self.assertIsNone(models_module)
        del apps.all_models['app_no_models'] 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:tests.py


注:本文中的django.apps.apps.all_models方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。