From 44e620972dbea7e11c255fff70fc8eeb08c99d12 Mon Sep 17 00:00:00 2001
From: Adrian Holovaty <adrian@holovaty.com>
Date: Mon, 27 Aug 2007 00:30:37 +0000
Subject: [PATCH] Changed 'validate' and 'runserver' management commands to
 display the number of errors. This was previous behavior before the
 management.py refactoring

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6022 bcc190cf-cafb-0310-a4f2-bffc1f526a37
---
 django/core/management/base.py               | 4 +++-
 django/core/management/commands/runserver.py | 2 +-
 django/core/management/commands/validate.py  | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/django/core/management/base.py b/django/core/management/base.py
index 866dec4407..173850716c 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -44,7 +44,7 @@ class BaseCommand(object):
             sys.stderr.write(self.style.ERROR(str('Error: %s\n' % e)))
             sys.exit(1)
 
-    def validate(self, app=None):
+    def validate(self, app=None, display_num_errors=False):
         """
         Validates the given app, raising CommandError for any errors.
 
@@ -61,6 +61,8 @@ class BaseCommand(object):
             s.seek(0)
             error_text = s.read()
             raise CommandError("One or more models did not validate:\n%s" % error_text)
+        if display_num_errors:
+            print "%s error%s found" % (num_errors, num_errors != 1 and 's' or '')
 
     def handle(self, *args, **options):
         raise NotImplementedError()
diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
index d06744e9fa..272ca18c07 100644
--- a/django/core/management/commands/runserver.py
+++ b/django/core/management/commands/runserver.py
@@ -37,7 +37,7 @@ class Command(BaseCommand):
         def inner_run():
             from django.conf import settings
             print "Validating models..."
-            self.validate()
+            self.validate(display_num_errors=True)
             print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
             print "Development server is running at http://%s:%s/" % (addr, port)
             print "Quit the server with %s." % quit_command
diff --git a/django/core/management/commands/validate.py b/django/core/management/commands/validate.py
index 2751f41abd..760d41c5bf 100644
--- a/django/core/management/commands/validate.py
+++ b/django/core/management/commands/validate.py
@@ -6,4 +6,4 @@ class Command(NoArgsCommand):
     requires_model_validation = False
 
     def handle_noargs(self, **options):
-        self.validate()
+        self.validate(display_num_errors=True)