From cc3b3ba93a7bfdd2ece739e97e36150a719acd3e Mon Sep 17 00:00:00 2001 From: Senko Rasic Date: Sat, 18 May 2013 17:51:14 +0200 Subject: Fixed #18990: Loaddata now complains if fixture doesn't exist The fixture named "initial_data" is exceptional though; if it doesn't exist, the error is not raised. This allows syncdb and flush management commands to attempt to load it without causing an error if it doesn't exist. --- django/core/management/commands/loaddata.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'django') diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py index c95d11cf60..fbafed3f92 100644 --- a/django/core/management/commands/loaddata.py +++ b/django/core/management/commands/loaddata.py @@ -162,9 +162,14 @@ class Command(BaseCommand): else: fixture_dirs = app_fixtures + list(settings.FIXTURE_DIRS) + [''] + label_found = False for fixture_dir in fixture_dirs: - self.process_dir(fixture_dir, fixture_name, compression_formats, - formats) + found = self.process_dir(fixture_dir, fixture_name, + compression_formats, formats) + label_found = label_found or found + + if fixture_name != 'initial_data' and not label_found: + raise CommandError("No fixture named '%s' found." % fixture_name) def process_dir(self, fixture_dir, fixture_name, compression_formats, serialization_formats): @@ -242,3 +247,5 @@ class Command(BaseCommand): raise CommandError( "No fixture data found for '%s'. (File format may be invalid.)" % (fixture_name)) + + return label_found -- cgit v1.3