summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-09-23 11:13:43 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-09-23 11:13:43 +0000
commit6cdd341dab3e634f5b969547a0d55d04a430e044 (patch)
tree80d61943ddc963902eaba682592a486ba17dd33b
parente8b572b912deee1c2cec493782b1172fccd75f90 (diff)
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
-rw-r--r--django/core/management.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/core/management.py b/django/core/management.py
index dd014c6021..6274d81b1b 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: