From 6bdd3840be63582531c3125a26cd00294e6f8346 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 10 Jul 2015 16:08:40 -0400 Subject: [PATCH] Improved whitespace in debug templates. Removed extra blank lines in the template text debug template, and prevented overindentation in the HTML debug template. --- django/views/debug.py | 50 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/django/views/debug.py b/django/views/debug.py index cd662ce23f..02a4848872 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -762,11 +762,9 @@ TECHNICAL_500_TEMPLATE = (""" {% for source_line in template_info.source_lines %} {% ifequal source_line.0 template_info.line %} {{ source_line.0 }} - - {{ template_info.before }} - {{ template_info.during }} - {{ template_info.after }} - + {{ template_info.before }}""" + """{{ template_info.during }}""" + """{{ template_info.after }} {% else %} {{ source_line.0 }} @@ -808,7 +806,7 @@ TECHNICAL_500_TEMPLATE = (""" {% endif %}
  1. -            {{ frame.context_line|escape }}
    {% if not is_email %} ...{% endif %}
+""" """{{ frame.context_line|escape }}{% if not is_email %} ...{% endif %} {% if frame.post_context and not is_email %}
    {% for line in frame.post_context %} @@ -883,12 +881,14 @@ Using engine {{ entry.backend.name }}: {% endif %}{% if template_info %} Template error: In template {{ template_info.name }}, error at line {{ template_info.line }} - {{ template_info.message }}{% for source_line in template_info.source_lines %} -{% ifequal source_line.0 template_info.line %} - {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }} -{% else %} - {{ source_line.0 }} : {{ source_line.1 }} -{% endifequal %}{% endfor %}{% endif %} + {{ template_info.message }}""" +"{% for source_line in template_info.source_lines %}" +"{% ifequal source_line.0 template_info.line %}" +" {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}" +"{% else %}" +" {{ source_line.0 }} : {{ source_line.1 }}" +"""{% endifequal %}{% endfor %}{% endif %} + Traceback:{% for frame in frames %} {% ifchanged frame.exc_cause %}{% if frame.exc_cause %}{% if frame.exc_cause_explicit %} The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception: @@ -1055,7 +1055,7 @@ Exception Value: {{ exception_value|force_escape }} """) -TECHNICAL_500_TEXT_TEMPLATE = """{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %} +TECHNICAL_500_TEXT_TEMPLATE = ("""{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %} {% firstof exception_value 'No exception message supplied' %} {% if request %} Request Method: {{ request.META.REQUEST_METHOD }} @@ -1081,16 +1081,18 @@ Using engine {{ entry.backend.name }}: {% endif %}{% if template_info %} Template error: In template {{ template_info.name }}, error at line {{ template_info.line }} - {{ template_info.message }}{% for source_line in template_info.source_lines %} -{% ifequal source_line.0 template_info.line %} - {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }} -{% else %} - {{ source_line.0 }} : {{ source_line.1 }} - {% endifequal %}{% endfor %}{% endif %}{% if frames %} -Traceback: -{% for frame in frames %} -{% ifchanged frame.exc_cause %} - {% if frame.exc_cause %} + {{ template_info.message }} +{% for source_line in template_info.source_lines %}""" +"{% ifequal source_line.0 template_info.line %}" +" {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}" +"{% else %}" +" {{ source_line.0 }} : {{ source_line.1 }}" +"""{% endifequal %}{% endfor %}{% endif %}{% if frames %} + +Traceback:""" +"{% for frame in frames %}" +"{% ifchanged frame.exc_cause %}" +" {% if frame.exc_cause %}" """ {% if frame.exc_cause_explicit %} The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception: {% else %} @@ -1127,7 +1129,7 @@ Using settings module {{ settings.SETTINGS_MODULE }}{% for k, v in settings.item You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code. -""" +""") TECHNICAL_404_TEMPLATE = """