Ticket #23406: migrations_loader.patch

File migrations_loader.patch, 1.3 KB (added by jdetaeye, 10 years ago)

Patch to support loading from Python packages in any format

  • django/db/migrations/loader.py

     django/db/migrations/loader.py | 15 +++++++--------
     1 file changed, 7 insertions(+), 8 deletions(-)
    
    diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py
    index b700616..16ffbf2 100644
    a b from __future__ import unicode_literals  
    22
    33from importlib import import_module
    44import os
     5import pkgutil
    56import sys
    67
    78from django.apps import apps
    class MigrationLoader(object):  
    8990                if was_loaded:
    9091                    six.moves.reload_module(module)
    9192            self.migrated_apps.add(app_config.label)
    92             directory = os.path.dirname(module.__file__)
    93             # Scan for .py files
    94             migration_names = set()
    95             for name in os.listdir(directory):
    96                 if name.endswith(".py"):
    97                     import_name = name.rsplit(".", 1)[0]
    98                     if import_name[0] not in "_.~":
    99                         migration_names.add(import_name)
     93            # Scan for migrations
     94            migration_names = set([
     95              name
     96              for _, name, is_pkg in pkgutil.iter_modules(module.__path__)
     97              if not is_pkg
     98              ])
    10099            # Load them
    101100            south_style_migrations = False
    102101            for migration_name in migration_names:
Back to Top