diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-11-24 21:13:33 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-11-24 21:13:33 +0000 |
| commit | f4879af2df1ecc92e924a3ff15b84e3cd448dbbf (patch) | |
| tree | d238cf22a2918c06e756450e0902efff340a4edd | |
| parent | 089ab18c025917f38a2e3731ae4024d4810df1ec (diff) | |
Fixed a bug introduced by [9527] -- empty/invalid fixtures were no longer being reported.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9528 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/management/commands/loaddata.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index 8b8ffa5512..5216e1522c 100644 --- a/django/core/management/commands/loaddata.py +++ b/django/core/management/commands/loaddata.py @@ -132,15 +132,17 @@ class Command(BaseCommand): return else: fixture_count += 1 + objects_in_fixture = 0 if verbosity > 0: print "Installing %s fixture '%s' from %s." % \ (format, fixture_name, humanize(fixture_dir)) try: objects = serializers.deserialize(format, fixture) for obj in objects: - object_count += 1 + objects_in_fixture += 1 models.add(obj.object.__class__) obj.save() + object_count += objects_in_fixture label_found = True except (SystemExit, KeyboardInterrupt): raise @@ -158,6 +160,17 @@ class Command(BaseCommand): (full_path, traceback.format_exc()))) return fixture.close() + + # If the fixture we loaded contains 0 objects, assume that an + # error was encountered during fixture loading. + if objects_in_fixture == 0: + sys.stderr.write( + self.style.ERROR("No fixture data found for '%s'. (File format may be invalid.)" % + (fixture_name))) + transaction.rollback() + transaction.leave_transaction_management() + return + except Exception, e: if verbosity > 1: print "No %s fixture '%s' in %s." % \ |
