diff --git a/django/template/__init__.py b/django/template/__init__.py
index ca1bd49..adf0352 100644
a
|
b
|
from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
|
59 | 59 | |
60 | 60 | # Exceptions |
61 | 61 | from django.template.base import (ContextPopException, InvalidTemplateLibrary, |
62 | | TemplateDoesNotExist, TemplateEncodingError, TemplateSyntaxError, |
63 | | VariableDoesNotExist) |
| 62 | TemplateDoesNotExist, IncludedTemplateDoesNotExist, TemplateEncodingError, |
| 63 | TemplateSyntaxError, VariableDoesNotExist) |
64 | 64 | |
65 | 65 | # Template parts |
66 | 66 | from django.template.base import (Context, FilterExpression, Lexer, Node, |
diff --git a/django/template/base.py b/django/template/base.py
index d934e05..063b5db 100644
a
|
b
|
class TemplateSyntaxError(Exception):
|
61 | 61 | class TemplateDoesNotExist(Exception): |
62 | 62 | pass |
63 | 63 | |
| 64 | class IncludedTemplateDoesNotExist(Exception): |
| 65 | pass |
| 66 | |
64 | 67 | class TemplateEncodingError(Exception): |
65 | 68 | pass |
66 | 69 | |
diff --git a/django/template/loader.py b/django/template/loader.py
index 279d8e8..885cd16 100644
a
|
b
|
|
26 | 26 | # installed, because pkg_resources is necessary to read eggs. |
27 | 27 | |
28 | 28 | from django.core.exceptions import ImproperlyConfigured |
29 | | from django.template.base import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins |
| 29 | from django.template.base import (Origin, Template, Context, |
| 30 | TemplateDoesNotExist, |
| 31 | IncludedTemplateDoesNotExist, |
| 32 | add_to_builtins) |
30 | 33 | from django.utils.importlib import import_module |
31 | 34 | from django.conf import settings |
32 | 35 | |
… |
… |
def get_template(template_name):
|
157 | 160 | template, origin = find_template(template_name) |
158 | 161 | if not hasattr(template, 'render'): |
159 | 162 | # template needs to be compiled |
160 | | template = get_template_from_string(template, origin, template_name) |
| 163 | try: |
| 164 | template = get_template_from_string(template, origin, template_name) |
| 165 | except TemplateDoesNotExist, included_template_name: |
| 166 | raise IncludedTemplateDoesNotExist, included_template_name |
161 | 167 | return template |
162 | 168 | |
163 | 169 | def get_template_from_string(source, origin=None, name=None): |
… |
… |
def select_template(template_name_list):
|
190 | 196 | for template_name in template_name_list: |
191 | 197 | try: |
192 | 198 | return get_template(template_name) |
193 | | except TemplateDoesNotExist: |
| 199 | except TemplateDoesNotExist, e: |
| 200 | if isinstance(e, IncludedTemplateDoesNotExist): |
| 201 | raise |
194 | 202 | continue |
195 | 203 | # If we get here, none of the templates could be loaded |
196 | 204 | raise TemplateDoesNotExist(', '.join(template_name_list)) |
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 475f923..6194f46 100644
a
|
b
|
class Templates(unittest.TestCase):
|
248 | 248 | r = tmpl.render(template.Context({})) |
249 | 249 | except template.TemplateSyntaxError, e: |
250 | 250 | settings.TEMPLATE_DEBUG = old_td |
251 | | self.assertEqual(e.args[0], 'Caught TemplateDoesNotExist while rendering: missing.html') |
| 251 | self.assertEqual(e.args[0], 'Caught IncludedTemplateDoesNotExist while rendering: missing.html') |
252 | 252 | self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r) |
253 | 253 | finally: |
254 | 254 | loader.template_source_loaders = old_loaders |
… |
… |
class Templates(unittest.TestCase):
|
274 | 274 | try: |
275 | 275 | r = tmpl.render(template.Context({})) |
276 | 276 | except template.TemplateSyntaxError, e: |
277 | | self.assertEqual(e.args[0], 'Caught TemplateDoesNotExist while rendering: missing.html') |
| 277 | self.assertEqual(e.args[0], 'Caught IncludedTemplateDoesNotExist while rendering: missing.html') |
278 | 278 | self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r) |
279 | 279 | |
280 | 280 | # For the cached loader, repeat the test, to ensure the first attempt did not cache a |
… |
… |
class Templates(unittest.TestCase):
|
283 | 283 | try: |
284 | 284 | tmpl.render(template.Context({})) |
285 | 285 | except template.TemplateSyntaxError, e: |
286 | | self.assertEqual(e.args[0], 'Caught TemplateDoesNotExist while rendering: missing.html') |
| 286 | self.assertEqual(e.args[0], 'Caught IncludedTemplateDoesNotExist while rendering: missing.html') |
287 | 287 | self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r) |
288 | 288 | finally: |
289 | 289 | loader.template_source_loaders = old_loaders |