diff --git a/django/core/defaulttags.py b/django/core/defaulttags.py
index 41595fcee0..3ff05a8ae1 100644
--- a/django/core/defaulttags.py
+++ b/django/core/defaulttags.py
@@ -230,11 +230,17 @@ class SsiNode(template.Node):
class ConstantIncludeNode(template.Node):
def __init__(self, template_path):
- t = template_loader.get_template(template_path)
- self.nodelist = t.nodelist
+ try:
+ t = template_loader.get_template(template_path)
+ self.nodelist = t.nodelist
+ except Exception, e:
+ self.nodelist = None
def render(self, context):
- return self.nodelist.render(context)
+ if self.nodelist:
+ return self.nodelist.render(context)
+ else:
+ return ''
class IncludeNode(template.Node):
def __init__(self, template_path_var):
@@ -247,7 +253,6 @@ class IncludeNode(template.Node):
t = template_loader.get_template(template_path)
return t.render(context)
except Exception, e:
- print e
return '' # Fail silently for invalid included templates.
diff --git a/django/core/template.py b/django/core/template.py
index 71a8e621c8..6f1da2a858 100644
--- a/django/core/template.py
+++ b/django/core/template.py
@@ -74,10 +74,18 @@ VARIABLE_TAG_END = '}}'
ALLOWED_VARIABLE_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.'
+#What to report as the origin of templates that come from non file sources (eg strings)
+UNKNOWN_SOURCE="