Kaydet (Commit) 4dcaa587 authored tarafından Simon Charette's avatar Simon Charette

Fixed #26135 -- Adjusted the migration questioner's handling of disabled apps.

This was causing an issue when calling the `migrate` command in a test case with
the `available_apps` attribute pointing to an application with migrations
disabled using the `MIGRATION_MODULES` setting.

Thanks to Tim Graham for the review.

Refs #24919
üst 229488c8
...@@ -38,6 +38,9 @@ class MigrationQuestioner(object): ...@@ -38,6 +38,9 @@ class MigrationQuestioner(object):
except LookupError: # It's a fake app. except LookupError: # It's a fake app.
return self.defaults.get("ask_initial", False) return self.defaults.get("ask_initial", False)
migrations_import_path = MigrationLoader.migrations_module(app_config.label) migrations_import_path = MigrationLoader.migrations_module(app_config.label)
if migrations_import_path is None:
# It's an application with migrations disabled.
return self.defaults.get("ask_initial", False)
try: try:
migrations_module = importlib.import_module(migrations_import_path) migrations_module = importlib.import_module(migrations_import_path)
except ImportError: except ImportError:
......
...@@ -71,3 +71,7 @@ Bugfixes ...@@ -71,3 +71,7 @@ Bugfixes
* Fixed a crash when using a reverse ``OneToOneField`` in * Fixed a crash when using a reverse ``OneToOneField`` in
``ModelAdmin.readonly_fields`` (:ticket:`26060`). ``ModelAdmin.readonly_fields`` (:ticket:`26060`).
* Fixed a crash when calling the ``migrate`` command in a test case with the
``available_apps`` attribute pointing to an application with migrations
disabled using the ``MIGRATION_MODULES`` setting (:ticket:`26135`).
from __future__ import unicode_literals
from django.db.migrations.questioner import MigrationQuestioner
from django.test import SimpleTestCase
from django.test.utils import override_settings
class QuestionerTests(SimpleTestCase):
@override_settings(
INSTALLED_APPS=['migrations'],
MIGRATION_MODULES={'migrations': None},
)
def test_ask_initial_with_disabled_migrations(self):
questioner = MigrationQuestioner()
self.assertIs(False, questioner.ask_initial('migrations'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment