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
This commit is contained in:
Adrian Holovaty 2007-08-27 00:30:37 +00:00
parent 4ea2afa4d5
commit 44e620972d
3 changed files with 5 additions and 3 deletions

View File

@ -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()

View File

@ -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

View File

@ -6,4 +6,4 @@ class Command(NoArgsCommand):
requires_model_validation = False
def handle_noargs(self, **options):
self.validate()
self.validate(display_num_errors=True)