Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 44e620972dbea7e11c255fff70fc8eeb08c99d12 1 parent 4ea2afa
Adrian Holovaty authored August 27, 2007
4  django/core/management/base.py
@@ -44,7 +44,7 @@ def execute(self, *args, **options):
44 44
             sys.stderr.write(self.style.ERROR(str('Error: %s\n' % e)))
45 45
             sys.exit(1)
46 46
 
47  
-    def validate(self, app=None):
  47
+    def validate(self, app=None, display_num_errors=False):
48 48
         """
49 49
         Validates the given app, raising CommandError for any errors.
50 50
 
@@ -61,6 +61,8 @@ def validate(self, app=None):
61 61
             s.seek(0)
62 62
             error_text = s.read()
63 63
             raise CommandError("One or more models did not validate:\n%s" % error_text)
  64
+        if display_num_errors:
  65
+            print "%s error%s found" % (num_errors, num_errors != 1 and 's' or '')
64 66
 
65 67
     def handle(self, *args, **options):
66 68
         raise NotImplementedError()
2  django/core/management/commands/runserver.py
@@ -37,7 +37,7 @@ def handle(self, addrport='', *args, **options):
37 37
         def inner_run():
38 38
             from django.conf import settings
39 39
             print "Validating models..."
40  
-            self.validate()
  40
+            self.validate(display_num_errors=True)
41 41
             print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
42 42
             print "Development server is running at http://%s:%s/" % (addr, port)
43 43
             print "Quit the server with %s." % quit_command
2  django/core/management/commands/validate.py
@@ -6,4 +6,4 @@ class Command(NoArgsCommand):
6 6
     requires_model_validation = False
7 7
 
8 8
     def handle_noargs(self, **options):
9  
-        self.validate()
  9
+        self.validate(display_num_errors=True)

0 notes on commit 44e6209

Please sign in to comment.
Something went wrong with that request. Please try again.