Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#16151 closed Cleanup/optimization (worksforme)

More informative message than "No fixtures found"

Reported by: Luc Saffre Owned by: nobody
Component: Core (Serialization) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When I run loaddata with a long list of fixture labels, and if for some of these there are no fixtures, then Django issues several times the message "No fixtures found." It would be more informative to mention the fixture name in that message. I suggest to change one line in django/core/management/commands/loaddata.py:

 if fixture_object_count == 0:
     if verbosity >= 1:
         self.stdout.write("No fixtures found.\n")

Change this to:

 if fixture_object_count == 0:
     if verbosity >= 1:
         self.stdout.write("No %r fixtures found.\n" % fixture_name)

Change History (2)

comment:1 by Aymeric Augustin, 14 years ago

Resolution: worksforme
Status: newclosed

I am unable to reproduce. That message is printed only once, if no objects are created from any fixture. Here's what I get:

% ./manage.py dumpdata > foo.json
% ./manage.py loaddata foo bar
Installed 19 object(s) from 1 fixture(s)
% ./manage.py loaddata bar baz
No fixtures found.

The piece of code you're mentionning is outside of the main loop: for fixture_label in fixture_labels: ...; fixture_name is leaked in scope from the last run of the loop. It's wrong to use it.

comment:2 by Luc Saffre, 14 years ago

Oops, you're right, my shot was too quick.

Note: See TracTickets for help on using tickets.
Back to Top