diff --git a/django/apps/cache.py b/django/apps/cache.py index 056aa9a60b0..e7adffecdb2 100644 --- a/django/apps/cache.py +++ b/django/apps/cache.py @@ -300,15 +300,15 @@ class AppCache(object): def has_app(self, app_name): """ - Returns the application config if one is registered and None otherwise. + Checks whether an application with this name exists in the app cache. + + app_name is the full name of the app eg. 'django.contrib.admin'. It's safe to call this method at import time, even while the app cache is being populated. It returns None for apps that aren't loaded yet. """ app_config = self.app_configs.get(app_name.rpartition(".")[2]) - if app_config is not None and app_config.name != app_name: - app_config = None - return app_config + return app_config is not None and app_config.name == app_name: def has_model(self, app_label, model_name): """