From 6cdd341dab3e634f5b969547a0d55d04a430e044 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 23 Sep 2006 11:13:43 +0000 Subject: [PATCH] Fixed #2425 -- Call validate() as part of generating SQL in order to catch a few more errors. Thanks, Simon Greenhill. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3802 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django/core/management.py b/django/core/management.py index dd014c60211..6274d81b1b2 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -1017,10 +1017,12 @@ def get_validation_errors(outfile, app=None): return len(e.errors) -def validate(outfile=sys.stdout): +def validate(outfile=sys.stdout, silent_success=False): "Validates all installed models." try: num_errors = get_validation_errors(outfile) + if silent_success and num_errors == 0: + return outfile.write('%s error%s found.\n' % (num_errors, num_errors != 1 and 's' or '')) except ImproperlyConfigured: outfile.write("Skipping validation because things aren't configured properly.") @@ -1337,6 +1339,7 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING, argv=None): action_mapping[action](args[1:]) else: from django.db import models + validate(silent_success=True) try: mod_list = [models.get_app(app_label) for app_label in args[1:]] except ImportError, e: