diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2009-12-19 14:27:26 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2009-12-19 14:27:26 +0000 |
| commit | 01acd99947b0723f5c9643aa4d438d553c82324c (patch) | |
| tree | 7e3c2b3d68ad3937f911b5a1550732984124e756 /django | |
| parent | f1ea26dd99415d376ab0e170bfce75fcfdeb7c01 (diff) | |
Fixed #6961 - loaddata fails if models is a package instead of a module
Thanks to pmd for report, zhaoz, mmalone and justinlilly for patch
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11914 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/commands/loaddata.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index e70f85b9a6..817ffaa83e 100644 --- a/django/core/management/commands/loaddata.py +++ b/django/core/management/commands/loaddata.py @@ -76,7 +76,17 @@ class Command(BaseCommand): if has_bz2: compression_types['bz2'] = bz2.BZ2File - app_fixtures = [os.path.join(os.path.dirname(app.__file__), 'fixtures') for app in get_apps()] + app_module_paths = [] + for app in get_apps(): + if hasattr(app, '__path__'): + # It's a 'models/' subpackage + for path in app.__path__: + app_module_paths.append(path) + else: + # It's a models.py module + app_module_paths.append(app.__file__) + + app_fixtures = [os.path.join(os.path.dirname(path), 'fixtures') for path in app_module_paths] for fixture_label in fixture_labels: parts = fixture_label.split('.') |
