summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorcammil <cammil@MacBook-Pro.local>2021-05-07 21:49:07 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-07-02 11:38:15 +0200
commit313c3d1aa14d80922003f841c257ec4e153f8653 (patch)
treeb7787a1f5f0d282ea7f0dfaa568d4af4f03c62a3 /django/template
parent9f3cce172f6913c5ac74272fa5fc07f847b4e112 (diff)
Fixed #28935 -- Fixed display of errors in extended blocks.
Get the template that caused the exception and get the exception info from that template, using the node that caused the exception.
Diffstat (limited to 'django/template')
-rw-r--r--django/template/base.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/django/template/base.py b/django/template/base.py
index 4972bd7c58..b47154d88a 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -926,8 +926,17 @@ class Node:
try:
return self.render(context)
except Exception as e:
- if context.template.engine.debug and not hasattr(e, 'template_debug'):
- e.template_debug = context.render_context.template.get_exception_info(e, self.token)
+ if context.template.engine.debug:
+ # Store the actual node that caused the exception.
+ if not hasattr(e, '_culprit_node'):
+ e._culprit_node = self
+ if (
+ not hasattr(e, 'template_debug') and
+ context.render_context.template.origin == e._culprit_node.origin
+ ):
+ e.template_debug = context.render_context.template.get_exception_info(
+ e, e._culprit_node.token,
+ )
raise
def __iter__(self):