Ticket #19126: runserver-validate.diff

File runserver-validate.diff, 898 bytes (added by direvus, 3 years ago)

Patch to catch and report validation errors in runserver.

  • django/core/management/commands/runserver.py

    diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
    index 391e0b4..f60bbc3 100644
    a b class Command(BaseCommand): 
    8989        quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
    9090
    9191        self.stdout.write("Validating models...\n\n")
    92         self.validate(display_num_errors=True)
     92        try:
     93            self.validate(display_num_errors=True)
     94        except CommandError as e:
     95            # Model validations errors are not always fatal; report the errors
     96            # and continue.
     97            error_text = str(e)
     98            self.stderr.write(error_text + '\n')
    9399        self.stdout.write((
    94100            "%(started_at)s\n"
    95101            "Django version %(version)s, using settings %(settings)r\n"
Back to Top