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


Python apps.clear_cache方法代码示例

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


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

示例1: user_model_swapped

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def user_model_swapped(**kwargs):
    if kwargs['setting'] == 'AUTH_USER_MODEL':
        apps.clear_cache()
        try:
            from django.contrib.auth import get_user_model
            UserModel = get_user_model()
        except ImproperlyConfigured:
            # Some tests set an invalid AUTH_USER_MODEL.
            pass
        else:
            from django.contrib.auth import backends
            backends.UserModel = UserModel

            from django.contrib.auth import forms
            forms.UserModel = UserModel

            from django.contrib.auth.handlers import modwsgi
            modwsgi.UserModel = UserModel

            from django.contrib.auth.management.commands import changepassword
            changepassword.UserModel = UserModel

            from django.contrib.auth import views
            views.UserModel = UserModel 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:26,代码来源:signals.py

示例2: setUp

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def setUp(self):
        super().setUp()

        apps.clear_cache()
        call_command("migrate", verbosity=0, interactive=False)
        # NOTE: Models must be imported after migrations are run. 
开发者ID:genialis,项目名称:resolwe,代码行数:8,代码来源:test_fields.py

示例3: setUp

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def setUp(self):
        apps.clear_cache()
        call_command("migrate", verbosity=0, interactive=False)

        super().setUp() 
开发者ID:genialis,项目名称:resolwe,代码行数:7,代码来源:test_index.py

示例4: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [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

示例5: setUp

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def setUp(self):
        apps.clear_cache() 
开发者ID:r4fek,项目名称:django-cassandra-engine,代码行数:4,代码来源:tests.py

示例6: test_clear_cache_clears_relation_tree

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def test_clear_cache_clears_relation_tree(self):
        # The apps.clear_cache is setUp() should have deleted all trees.
        # Exclude abstract models that are not included in the Apps registry
        # and have no cache.
        all_models_with_cache = (m for m in self.all_models if not m._meta.abstract)
        for m in all_models_with_cache:
            self.assertNotIn('_relation_tree', m._meta.__dict__) 
开发者ID:r4fek,项目名称:django-cassandra-engine,代码行数:9,代码来源:tests.py

示例7: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [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

示例8: model_cleanup

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def model_cleanup(self):
        create_models()
        importlib.reload(import_module(settings.ROOT_URLCONF))
        app_config = apps.get_app_config("django_models_from_csv")
        hydrate_models_and_permissions(app_config)
        apps.clear_cache()
        clear_url_caches() 
开发者ID:propublica,项目名称:django-collaborative,代码行数:9,代码来源:models.py

示例9: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [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

示例10: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [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

示例11: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def tearDown(self):
        apps.clear_cache() 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:tests.py

示例12: tearDown

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def tearDown(self):
        for model in Article, Authors, Reviewers, Scientist:
            model._meta.managed = False

        apps.app_configs['model_options'].models = self._old_models
        apps.all_models['model_options'] = self._old_models
        apps.clear_cache() 
开发者ID:nesdis,项目名称:djongo,代码行数:9,代码来源:test_tablespaces.py

示例13: setUp

# 需要导入模块: from django.apps import apps [as 别名]
# 或者: from django.apps.apps import clear_cache [as 别名]
def setUp(self):
        from .test_app.models import TestModel
        from .test_app.elastic_indexes import TestSearchIndex
        from .test_app.viewsets import TestViewSet

        super().setUp()

        apps.clear_cache()
        call_command("migrate", verbosity=0, interactive=False)

        index_builder.indexes = [TestSearchIndex()]
        index_builder.register_signals()

        # Prepare users and groups
        user_model = get_user_model()
        self.user_1 = user_model.objects.create(username="user_one")
        self.user_2 = user_model.objects.create(username="user_two")
        group = Group.objects.create(name="group")
        group.user_set.add(self.user_2)

        tzone = get_current_timezone()
        # Prepare test data
        test_obj_1 = TestModel.objects.create(
            name="Object name 1",
            number=43,
            date=datetime.datetime(2018, 1, 1, 0, 0, tzinfo=tzone),
        )
        test_obj_2 = TestModel.objects.create(
            name="Object name 2",
            number=44,
            date=datetime.datetime(2017, 1, 1, 0, 0, tzinfo=tzone),
        )
        test_obj_3 = TestModel.objects.create(
            name="Object name 3",
            number=45,
            date=datetime.datetime(2016, 1, 1, 0, 0, tzinfo=tzone),
        )

        # Assing permissions
        assign_perm("view_testmodel", self.user_1, test_obj_1)
        assign_perm("view_testmodel", group, test_obj_2)
        assign_perm("view_testmodel", AnonymousUser(), test_obj_3)

        # Prepare test viewset
        self.test_viewset = TestViewSet.as_view(actions={"post": "list_with_post",}) 
开发者ID:genialis,项目名称:resolwe,代码行数:47,代码来源:test_viewsets.py


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