Ticket #21849: 21849.diff

File 21849.diff, 2.0 KB (added by Tim Graham, 10 years ago)
  • django/core/management/base.py

    diff --git a/django/core/management/base.py b/django/core/management/base.py
    index 5ac1cdf..9e2013e 100644
    a b class BaseCommand(object):  
    371371        all_issues = checks.run_checks(app_configs=app_configs, tags=tags)
    372372
    373373        msg = ""
     374        issue_count = 0
     375
    374376        if all_issues:
    375377            debugs = [e for e in all_issues if e.level < checks.INFO and not e.is_silenced()]
    376378            infos = [e for e in all_issues if checks.INFO <= e.level < checks.WARNING and not e.is_silenced()]
    class BaseCommand(object):  
    387389
    388390            for issues, group_name in sorted_issues:
    389391                if issues:
     392                    issue_count += len(issues)
    390393                    formatted = (
    391394                        color_style().ERROR(force_str(e))
    392395                        if e.is_serious()
    class BaseCommand(object):  
    394397                        for e in issues)
    395398                    formatted = "\n".join(sorted(formatted))
    396399                    msg += '\n%s:\n%s\n' % (group_name, formatted)
    397 
    398             msg = "System check identified some issues:\n%s" % msg
     400            if msg:
     401                msg = "System check identified some issues:\n%s" % msg
    399402
    400403        if display_num_errors:
    401404            if msg:
    402405                msg += '\n'
    403406            msg += "System check identified %s." % (
    404                 "no issues" if len(all_issues) == 0 else
    405                 "1 issue" if len(all_issues) == 1 else
    406                 "%s issues" % len(all_issues)
     407                "no issues" if issue_count == 0 else
     408                "1 issue" if issue_count == 1 else
     409                "%s issues" % issue_count
    407410            )
    408411
    409412        if any(e.is_serious() and not e.is_silenced() for e in all_issues):
    410413            raise CommandError(msg)
    411         elif msg and all_issues:
     414        elif msg and issue_count:
    412415            self.stderr.write(msg)
    413416        elif msg:
    414417            self.stdout.write(msg)
Back to Top