|
@@ -1,3 +1,4 @@
|
|
|
+from django.apps import apps
|
|
|
from django.conf import settings
|
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
|
from django.db import DEFAULT_DB_ALIAS, connections, migrations
|
|
@@ -46,7 +47,11 @@ class Command(BaseCommand):
|
|
|
migration_name = options['migration_name']
|
|
|
no_optimize = options['no_optimize']
|
|
|
squashed_name = options['squashed_name']
|
|
|
-
|
|
|
+ # Validate app_label.
|
|
|
+ try:
|
|
|
+ apps.get_app_config(app_label)
|
|
|
+ except LookupError as err:
|
|
|
+ raise CommandError(str(err))
|
|
|
# Load the current graph state, check the app and migration they asked for exists
|
|
|
loader = MigrationLoader(connections[DEFAULT_DB_ALIAS])
|
|
|
if app_label not in loader.migrated_apps:
|