summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2020-07-22 01:04:06 -0400
committerGitHub <noreply@github.com>2020-07-22 07:04:06 +0200
commitff55adbd0da6618abaf265d16196bf54f81aa77a (patch)
treea4b16306b57c8b49bd62cbf9c03922d9a80b8b70 /django
parent3f2821af6bc48fa8e7970c1ce27bc54c3172545e (diff)
Reverted "Fixed #30300 -- Allowed migrations to be loaded from directories without __init__.py file."
This reverts commit 3cd3bebe8921e14b911b36b2a1cbceef8fb6294e.
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/loader.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py
index cb61aeca16..95a5062ec9 100644
--- a/django/db/migrations/loader.py
+++ b/django/db/migrations/loader.py
@@ -88,6 +88,11 @@ class MigrationLoader:
continue
raise
else:
+ # Empty directories are namespaces.
+ # getattr() needed on PY36 and older (replace w/attribute access).
+ if getattr(module, '__file__', None) is None:
+ self.unmigrated_apps.add(app_config.label)
+ continue
# Module is not a package (e.g. migrations.py).
if not hasattr(module, '__path__'):
self.unmigrated_apps.add(app_config.label)
@@ -95,14 +100,11 @@ class MigrationLoader:
# Force a reload if it's already loaded (tests need this)
if was_loaded:
reload(module)
+ self.migrated_apps.add(app_config.label)
migration_names = {
name for _, name, is_pkg in pkgutil.iter_modules(module.__path__)
if not is_pkg and name[0] not in '_~'
}
- if migration_names or self.ignore_no_migrations:
- self.migrated_apps.add(app_config.label)
- else:
- self.unmigrated_apps.add(app_config.label)
# Load migrations
for migration_name in migration_names:
migration_path = '%s.%s' % (module_name, migration_name)