1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #21015 -- Fixed MigrationLoader when importlib.import_module returns a file module or an empty directory.

This commit is contained in:
Loic Bistuer
2013-09-06 03:51:31 +07:00
committed by Tim Graham
parent 82bbb9fe81
commit e1266e50b2
5 changed files with 23 additions and 0 deletions

View File

@@ -64,6 +64,13 @@ class MigrationLoader(object):
self.unmigrated_apps.add(app_label)
continue
raise
else:
# PY3 will happily import empty dirs as namespaces.
if not hasattr(module, '__file__'):
continue
# Module is not a package (e.g. migrations.py).
if not hasattr(module, '__path__'):
continue
self.migrated_apps.add(app_label)
directory = os.path.dirname(module.__file__)
# Scan for .py[c|o] files