diff options
| author | Peter Inglesby <peter.inglesby@gmail.com> | 2015-05-12 10:02:23 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-05-22 11:08:25 -0400 |
| commit | 0688a7946afac04123309afd29c95319a8d59392 (patch) | |
| tree | 01c9b48d0d39d2538d288c34c5fa1baa91f00dd1 /django | |
| parent | 70faaccc3eef916e1b1ba5c2e93799074e66a5c3 (diff) | |
Fixed #24776 -- Improved apps.get_app_config() error message on fully-qualified package names.
Diffstat (limited to 'django')
| -rw-r--r-- | django/apps/registry.py | 7 | ||||
| -rw-r--r-- | django/core/management/commands/dumpdata.py | 12 |
2 files changed, 12 insertions, 7 deletions
diff --git a/django/apps/registry.py b/django/apps/registry.py index 96d4db5f17..0602c4ff57 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -147,7 +147,12 @@ class Apps(object): try: return self.app_configs[app_label] except KeyError: - raise LookupError("No installed app with label '%s'." % app_label) + message = "No installed app with label '%s'." % app_label + for app_config in self.get_app_configs(): + if app_config.name == app_label: + message += " Did you mean '%s'?" % app_config.label + break + raise LookupError(message) # This method is performance-critical at least for Django's test suite. @lru_cache.lru_cache(maxsize=None) diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index da1584d561..01b229ce36 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -68,8 +68,8 @@ class Command(BaseCommand): else: try: app_config = apps.get_app_config(exclude) - except LookupError: - raise CommandError('Unknown app in excludes: %s' % exclude) + except LookupError as e: + raise CommandError(str(e)) excluded_apps.add(app_config) if len(app_labels) == 0: @@ -87,8 +87,8 @@ class Command(BaseCommand): app_label, model_label = label.split('.') try: app_config = apps.get_app_config(app_label) - except LookupError: - raise CommandError("Unknown application: %s" % app_label) + except LookupError as e: + raise CommandError(str(e)) if app_config.models_module is None or app_config in excluded_apps: continue try: @@ -111,8 +111,8 @@ class Command(BaseCommand): app_label = label try: app_config = apps.get_app_config(app_label) - except LookupError: - raise CommandError("Unknown application: %s" % app_label) + except LookupError as e: + raise CommandError(str(e)) if app_config.models_module is None or app_config in excluded_apps: continue app_list[app_config] = None |
