diff --git a/django/views/debug.py b/django/views/debug.py
index e3be2a7dcd..5f6f17d016 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -431,11 +431,11 @@ TECHNICAL_500_TEMPLATE = """
{% if frame.context_line %}
{% if frame.pre_context %}
-
{% for line in frame.pre_context %}- {{ line|escape }}
{% endfor %}
+
{% for line in frame.pre_context %}{% if line %}- {{ line|escape }}
{% endif %}{% endfor %}
{% endif %}
- {{ frame.context_line|escape }} ...
{% if frame.post_context %}
-
{% for line in frame.post_context %}- {{ line|escape }}
{% endfor %}
+
{% for line in frame.post_context %}{% if line %}- {{ line|escape }}
{% endif %}{% endfor %}
{% endif %}
{% endif %}