From 29ddae7436e84f4713c7babeabdf9a1fa62d6543 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Fri, 24 Jan 2014 20:07:14 -0700 Subject: [PATCH] Fixed #21871 -- Fixed Apps.is_installed() for apps with custom label. Thanks Aymeric for design discussion. --- django/apps/registry.py | 3 +-- tests/apps/apps.py | 1 + tests/apps/tests.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/django/apps/registry.py b/django/apps/registry.py index fcd5f576e6..649ba42d78 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -204,8 +204,7 @@ class Apps(object): It's safe to call this method at import time, even while the registry is being populated. It returns False for apps that aren't loaded yet. """ - app_config = self.app_configs.get(app_name.rpartition(".")[2]) - return app_config is not None and app_config.name == app_name + return any(ac.name == app_name for ac in self.app_configs.values()) def get_containing_app_config(self, object_name): """ diff --git a/tests/apps/apps.py b/tests/apps/apps.py index a2c49fcbff..7faa63e435 100644 --- a/tests/apps/apps.py +++ b/tests/apps/apps.py @@ -10,6 +10,7 @@ class MyAdmin(AppConfig): class MyAuth(AppConfig): name = 'django.contrib.auth' + label = 'myauth' verbose_name = "All your password are belong to us." diff --git a/tests/apps/tests.py b/tests/apps/tests.py index ad5fd0d609..139bc06a66 100644 --- a/tests/apps/tests.py +++ b/tests/apps/tests.py @@ -109,6 +109,7 @@ class AppsTests(TestCase): @override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS) def test_is_installed(self): self.assertTrue(apps.is_installed('django.contrib.admin')) + self.assertTrue(apps.is_installed('django.contrib.auth')) self.assertTrue(apps.is_installed('django.contrib.staticfiles')) self.assertFalse(apps.is_installed('django.contrib.webdesign'))