當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。