Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@adrianholovaty adrianholovaty authored
View
4 django/core/management/base.py
@@ -44,7 +44,7 @@ def execute(self, *args, **options):
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 @@ def validate(self, app=None):
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
2  django/core/management/commands/runserver.py
@@ -37,7 +37,7 @@ def handle(self, addrport='', *args, **options):
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
2  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)
Please sign in to comment.
Something went wrong with that request. Please try again.