Ticket #1332: management.py+get_validation_errors.patch
File management.py+get_validation_errors.patch, 1.4 KB (added by , 19 years ago) |
---|
-
django_src/django/core/management.py
402 402 403 403 # First, try validating the models. 404 404 s = StringIO() 405 num_errors = get_validation_errors(s )405 num_errors = get_validation_errors(s, selected_mod=mod) 406 406 if num_errors: 407 407 sys.stderr.write("Error: %s couldn't be installed, because there were errors in your model:\n" % mod_name) 408 408 s.seek(0) … … 646 646 self.errors.append((opts, error)) 647 647 self.outfile.write("%s.%s: %s\n" % (opts.app_label, opts.module_name, error)) 648 648 649 def get_validation_errors(outfile): 650 "Validates all installed models. Writes errors, if any, to outfile. Returns number of errors." 649 def get_validation_errors(outfile, selected_mod=None): 650 "Validates all installed models or models from 'selected_mod'.Writes errors, if any, to outfile.Returns number of errors." 651 651 652 import django.models 652 653 from django.core import meta 653 654 e = ModelErrorCollection(outfile) 654 module_list = meta.get_installed_model_modules() 655 if not selected_mod: 656 module_list = meta.get_installed_model_modules() 657 else: 658 module_list = selected_mod, 655 659 for module in module_list: 656 660 for mod in module._MODELS: 657 661 opts = mod._meta