summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2016-09-08 18:24:22 -0700
committerGitHub <noreply@github.com>2016-09-08 18:24:22 -0700
commit331ca5391eb64cbac3a001209257beb93522d587 (patch)
treee6dcdf38907001da099892c79cc17a23d9f223f3 /django
parent7ca3b391b611eb710c4c1d613e2f672591097a00 (diff)
Fixed #27175 -- Deprecated silencing exceptions from the {% include %} template tag.
Thanks Tim Graham for the review.
Diffstat (limited to 'django')
-rw-r--r--django/template/loader_tags.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index 839eacfd95..2ed145c248 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -1,8 +1,10 @@
import logging
import posixpath
+import warnings
from collections import defaultdict
from django.utils import six
+from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.safestring import mark_safe
from .base import (
@@ -208,10 +210,17 @@ class IncludeNode(Node):
return template.render(context.new(values))
with context.push(**values):
return template.render(context)
- except Exception:
+ except Exception as e:
if context.template.engine.debug:
raise
template_name = getattr(context, 'template_name', None) or 'unknown'
+ warnings.warn(
+ "Rendering {%% include '%s' %%} raised %s. In Django 2.1, "
+ "this exception will be raised rather than silenced and "
+ "rendered as an empty string." %
+ (template_name, e.__class__.__name__),
+ RemovedInDjango21Warning,
+ )
logger.warning(
"Exception raised while rendering {%% include %%} for "
"template '%s'. Empty string rendered instead.",