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:
parent
4ea2afa4d5
commit
44e620972d
|
@ -44,7 +44,7 @@ class BaseCommand(object):
|
||||||
sys.stderr.write(self.style.ERROR(str('Error: %s\n' % e)))
|
sys.stderr.write(self.style.ERROR(str('Error: %s\n' % e)))
|
||||||
sys.exit(1)
|
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.
|
Validates the given app, raising CommandError for any errors.
|
||||||
|
|
||||||
|
@ -61,6 +61,8 @@ class BaseCommand(object):
|
||||||
s.seek(0)
|
s.seek(0)
|
||||||
error_text = s.read()
|
error_text = s.read()
|
||||||
raise CommandError("One or more models did not validate:\n%s" % error_text)
|
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):
|
def handle(self, *args, **options):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Command(BaseCommand):
|
||||||
def inner_run():
|
def inner_run():
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
print "Validating models..."
|
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 "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
|
||||||
print "Development server is running at http://%s:%s/" % (addr, port)
|
print "Development server is running at http://%s:%s/" % (addr, port)
|
||||||
print "Quit the server with %s." % quit_command
|
print "Quit the server with %s." % quit_command
|
||||||
|
|
|
@ -6,4 +6,4 @@ class Command(NoArgsCommand):
|
||||||
requires_model_validation = False
|
requires_model_validation = False
|
||||||
|
|
||||||
def handle_noargs(self, **options):
|
def handle_noargs(self, **options):
|
||||||
self.validate()
|
self.validate(display_num_errors=True)
|
||||||
|
|
Loading…
Reference in New Issue