diff --git a/django/apps/registry.py b/django/apps/registry.py index f88fb73dd6..a0cd5e0abf 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -192,7 +192,7 @@ class Apps(object): app_models[model_name] = model self.clear_cache() - def has_app(self, app_name): + def is_installed(self, app_name): """ Checks whether an application with this name exists in the registry. diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index 0626c5aa45..8b81f6c68e 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -160,10 +160,10 @@ class AdminSite(object): The default implementation checks that admin and contenttypes apps are installed, as well as the auth context processor. """ - if not apps.has_app('django.contrib.admin'): + if not apps.is_installed('django.contrib.admin'): raise ImproperlyConfigured("Put 'django.contrib.admin' in your " "INSTALLED_APPS setting in order to use the admin application.") - if not apps.has_app('django.contrib.contenttypes'): + if not apps.is_installed('django.contrib.contenttypes'): raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in " "your INSTALLED_APPS setting in order to use the admin application.") if 'django.contrib.auth.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS: diff --git a/django/contrib/admin/templatetags/admin_static.py b/django/contrib/admin/templatetags/admin_static.py index 446ab4cab5..77473c2e00 100644 --- a/django/contrib/admin/templatetags/admin_static.py +++ b/django/contrib/admin/templatetags/admin_static.py @@ -3,7 +3,7 @@ from django.template import Library register = Library() -if apps.has_app('django.contrib.staticfiles'): +if apps.is_installed('django.contrib.staticfiles'): from django.contrib.staticfiles.templatetags.staticfiles import static else: from django.templatetags.static import static diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py index 7244a6d34e..b0c35b9d06 100644 --- a/django/contrib/messages/tests/base.py +++ b/django/contrib/messages/tests/base.py @@ -15,7 +15,7 @@ from django.utils.translation import ugettext_lazy def skipUnlessAuthIsInstalled(func): return skipUnless( - apps.has_app('django.contrib.auth'), + apps.is_installed('django.contrib.auth'), "django.contrib.auth isn't installed")(func) diff --git a/django/contrib/redirects/middleware.py b/django/contrib/redirects/middleware.py index 52c9a49a8f..4894e30216 100644 --- a/django/contrib/redirects/middleware.py +++ b/django/contrib/redirects/middleware.py @@ -15,7 +15,7 @@ class RedirectFallbackMiddleware(object): response_redirect_class = http.HttpResponsePermanentRedirect def __init__(self): - if not apps.has_app('django.contrib.sites'): + if not apps.is_installed('django.contrib.sites'): raise ImproperlyConfigured( "You cannot use RedirectFallbackMiddleware when " "django.contrib.sites is not installed." diff --git a/django/contrib/sitemaps/tests/test_flatpages.py b/django/contrib/sitemaps/tests/test_flatpages.py index 4e9deb8de4..c284c66c0d 100644 --- a/django/contrib/sitemaps/tests/test_flatpages.py +++ b/django/contrib/sitemaps/tests/test_flatpages.py @@ -10,7 +10,7 @@ from .base import SitemapTestsBase class FlatpagesSitemapTests(SitemapTestsBase): - @skipUnless(apps.has_app('django.contrib.flatpages'), + @skipUnless(apps.is_installed('django.contrib.flatpages'), "django.contrib.flatpages app not installed.") def test_flatpage_sitemap(self): "Basic FlatPage sitemap test" diff --git a/django/contrib/sitemaps/tests/test_http.py b/django/contrib/sitemaps/tests/test_http.py index e8c3409c74..2f9ebd8fad 100644 --- a/django/contrib/sitemaps/tests/test_http.py +++ b/django/contrib/sitemaps/tests/test_http.py @@ -118,7 +118,7 @@ class HTTPSitemapTests(SitemapTestsBase): """ % date.today() self.assertXMLEqual(response.content.decode('utf-8'), expected_content) - @skipUnless(apps.has_app('django.contrib.sites'), + @skipUnless(apps.is_installed('django.contrib.sites'), "django.contrib.sites app not installed.") def test_sitemap_get_urls_no_site_1(self): """ diff --git a/django/test/client.py b/django/test/client.py index a2da8bcd38..9197a5ab1b 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -390,7 +390,7 @@ class Client(RequestFactory): """ Obtains the current session variables. """ - if apps.has_app('django.contrib.sessions'): + if apps.is_installed('django.contrib.sessions'): engine = import_module(settings.SESSION_ENGINE) cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None) if cookie: @@ -551,7 +551,7 @@ class Client(RequestFactory): """ user = authenticate(**credentials) if (user and user.is_active and - apps.has_app('django.contrib.sessions')): + apps.is_installed('django.contrib.sessions')): engine = import_module(settings.SESSION_ENGINE) # Create a fake request that goes through request middleware diff --git a/docs/ref/applications.txt b/docs/ref/applications.txt index 0713da76ed..a44062808e 100644 --- a/docs/ref/applications.txt +++ b/docs/ref/applications.txt @@ -203,7 +203,7 @@ Application registry given ``app_label``. Raises :exc:`~exceptions.LookupError` if no such application exists. -.. method:: apps.has_app(app_name) +.. method:: apps.is_installed(app_name) Checks whether an application with the given name exists in the registry. ``app_name`` is the full name of the app, e.g. 'django.contrib.admin'. diff --git a/tests/apps/tests.py b/tests/apps/tests.py index c31174a1f1..ad5fd0d609 100644 --- a/tests/apps/tests.py +++ b/tests/apps/tests.py @@ -107,10 +107,10 @@ class AppsTests(TestCase): apps.get_app_config('webdesign') @override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS) - def test_has_app(self): - self.assertTrue(apps.has_app('django.contrib.admin')) - self.assertTrue(apps.has_app('django.contrib.staticfiles')) - self.assertFalse(apps.has_app('django.contrib.webdesign')) + def test_is_installed(self): + self.assertTrue(apps.is_installed('django.contrib.admin')) + self.assertTrue(apps.is_installed('django.contrib.staticfiles')) + self.assertFalse(apps.is_installed('django.contrib.webdesign')) @override_settings(INSTALLED_APPS=['apps.apps.RelabeledAppsConfig']) def test_relabeling(self):