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
This commit is contained in:
parent
089ab18c02
commit
f4879af2df
|
@ -132,15 +132,17 @@ class Command(BaseCommand):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
fixture_count += 1
|
fixture_count += 1
|
||||||
|
objects_in_fixture = 0
|
||||||
if verbosity > 0:
|
if verbosity > 0:
|
||||||
print "Installing %s fixture '%s' from %s." % \
|
print "Installing %s fixture '%s' from %s." % \
|
||||||
(format, fixture_name, humanize(fixture_dir))
|
(format, fixture_name, humanize(fixture_dir))
|
||||||
try:
|
try:
|
||||||
objects = serializers.deserialize(format, fixture)
|
objects = serializers.deserialize(format, fixture)
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
object_count += 1
|
objects_in_fixture += 1
|
||||||
models.add(obj.object.__class__)
|
models.add(obj.object.__class__)
|
||||||
obj.save()
|
obj.save()
|
||||||
|
object_count += objects_in_fixture
|
||||||
label_found = True
|
label_found = True
|
||||||
except (SystemExit, KeyboardInterrupt):
|
except (SystemExit, KeyboardInterrupt):
|
||||||
raise
|
raise
|
||||||
|
@ -158,6 +160,17 @@ class Command(BaseCommand):
|
||||||
(full_path, traceback.format_exc())))
|
(full_path, traceback.format_exc())))
|
||||||
return
|
return
|
||||||
fixture.close()
|
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:
|
except Exception, e:
|
||||||
if verbosity > 1:
|
if verbosity > 1:
|
||||||
print "No %s fixture '%s' in %s." % \
|
print "No %s fixture '%s' in %s." % \
|
||||||
|
|
Loading…
Reference in New Issue