summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-07-26 16:33:32 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-07-26 16:33:32 +0100
commit6b39010d5793689af2d3e5d9a2f9e92d99d0f105 (patch)
treea580c9fbd629db4330121dc30fe1d238a372466c
parent88e1e6f9f3fc6eb9f148805b6df6ec8af4cf6977 (diff)
Remove nasty error message checking hack
-rw-r--r--django/core/management/commands/migrate.py16
1 files changed, 2 insertions, 14 deletions
diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py
index 8e3c79a431..d9fbb846ac 100644
--- a/django/core/management/commands/migrate.py
+++ b/django/core/management/commands/migrate.py
@@ -12,6 +12,7 @@ from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.loader import AmbiguityError
from django.utils.datastructures import SortedDict
from django.utils.importlib import import_module
+from django.utils.module_loading import module_has_submodule, import_by_path
class Command(BaseCommand):
@@ -40,21 +41,8 @@ class Command(BaseCommand):
# Import the 'management' module within each installed app, to register
# dispatcher events.
for app_name in settings.INSTALLED_APPS:
- try:
+ if module_has_submodule(import_module(app_name), "management"):
import_module('.management', app_name)
- except ImportError as exc:
- # This is slightly hackish. We want to ignore ImportErrors
- # if the "management" module itself is missing -- but we don't
- # want to ignore the exception if the management module exists
- # but raises an ImportError for some reason. The only way we
- # can do this is to check the text of the exception. Note that
- # we're a bit broad in how we check the text, because different
- # Python implementations may not use the same text.
- # CPython uses the text "No module named management"
- # PyPy uses "No module named myproject.myapp.management"
- msg = exc.args[0]
- if not msg.startswith('No module named') or 'management' not in msg:
- raise
# Get the database we're operating from
db = options.get('database')