summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/showmigrations.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/django/core/management/commands/showmigrations.py b/django/core/management/commands/showmigrations.py
index abac283160..4c86ba1a17 100644
--- a/django/core/management/commands/showmigrations.py
+++ b/django/core/management/commands/showmigrations.py
@@ -1,4 +1,7 @@
-from django.core.management.base import BaseCommand, CommandError
+import sys
+
+from django.apps import apps
+from django.core.management.base import BaseCommand
from django.db import DEFAULT_DB_ALIAS, connections
from django.db.migrations.loader import MigrationLoader
@@ -45,12 +48,15 @@ class Command(BaseCommand):
return self.show_list(connection, options['app_label'])
def _validate_app_names(self, loader, app_names):
- invalid_apps = []
+ has_bad_names = False
for app_name in app_names:
- if app_name not in loader.migrated_apps:
- invalid_apps.append(app_name)
- if invalid_apps:
- raise CommandError('No migrations present for: %s' % (', '.join(sorted(invalid_apps))))
+ try:
+ apps.get_app_config(app_name)
+ except LookupError as err:
+ self.stderr.write(str(err))
+ has_bad_names = True
+ if has_bad_names:
+ sys.exit(2)
def show_list(self, connection, app_names=None):
"""
@@ -129,3 +135,5 @@ class Command(BaseCommand):
self.stdout.write("[X] %s.%s%s" % (node.key[0], node.key[1], deps))
else:
self.stdout.write("[ ] %s.%s%s" % (node.key[0], node.key[1], deps))
+ if not plan:
+ self.stdout.write('(no migrations)', self.style.ERROR)