Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16151 closed Cleanup/optimization (worksforme)

More informative message than "No fixtures found"

Reported by: lsaffre 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:

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)

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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 Changed 3 years ago by lsaffre

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.