Ticket #1332: management.py+get_validation_errors.patch

File management.py+get_validation_errors.patch, 1.4 KB (added by jakamkon@…, 19 years ago)
  • django_src/django/core/management.py

     
    402402
    403403    # First, try validating the models.
    404404    s = StringIO()
    405     num_errors = get_validation_errors(s)
     405    num_errors = get_validation_errors(s, selected_mod=mod)
    406406    if num_errors:
    407407        sys.stderr.write("Error: %s couldn't be installed, because there were errors in your model:\n" % mod_name)
    408408        s.seek(0)
     
    646646        self.errors.append((opts, error))
    647647        self.outfile.write("%s.%s: %s\n" % (opts.app_label, opts.module_name, error))
    648648
    649 def get_validation_errors(outfile):
    650     "Validates all installed models. Writes errors, if any, to outfile. Returns number of errors."
     649def 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
    651652    import django.models
    652653    from django.core import meta
    653654    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,       
    655659    for module in module_list:
    656660        for mod in module._MODELS:
    657661            opts = mod._meta
Back to Top