Ticket #12787: 12787.diff

File 12787.diff, 5.0 KB (added by Karen Tracey, 15 years ago)
  • django/template/loaders/cached.py

     
    3737        if template_name not in self.template_cache:
    3838            template, origin = self.find_template(template_name, template_dirs)
    3939            if not hasattr(template, 'render'):
    40                 template = get_template_from_string(template, origin, template_name)
     40                try:
     41                    template = get_template_from_string(template, origin, template_name)
     42                except TemplateDoesNotExist:
     43                    return template, origin
    4144            self.template_cache[template_name] = template
    4245        return self.template_cache[template_name], None
    4346
  • django/template/loader_tags.py

     
    9797            raise TemplateSyntaxError(error_msg)
    9898        if hasattr(parent, 'render'):
    9999            return parent # parent is a Template object
    100         try:
    101             return get_template(parent)
    102         except TemplateDoesNotExist:
    103             raise TemplateSyntaxError("Template %r cannot be extended, because it doesn't exist" % parent)
     100        return get_template(parent)
    104101
    105102    def render(self, context):
    106103        compiled_parent = self.get_parent(context)
  • django/template/loader.py

     
    4444    def load_template(self, template_name, template_dirs=None):
    4545        source, display_name = self.load_template_source(template_name, template_dirs)
    4646        origin = make_origin(display_name, self.load_template_source, template_name, template_dirs)
    47         template = get_template_from_string(source, origin, template_name)
    48         return template, None
     47        try:
     48            template = get_template_from_string(source, origin, template_name)
     49            return template, None
     50        except TemplateDoesNotExist:
     51            return source, display_name
    4952
    5053    def load_template_source(self, template_name, template_dirs=None):
    5154        """
  • tests/regressiontests/views/tests/debug.py

     
    4949                    "Failed to find 'raise BrokenException' in last frame of traceback, instead found: %s" %
    5050                        raising_loc)
    5151
     52    def test_extends_error(self):
     53        try:
     54            self.client.get(reverse('test_extends'))
     55        except TemplateSyntaxError, e:
     56            self.assertEquals(e.args[0], "Caught TemplateDoesNotExist while rendering: missing.html")
     57
     58
  • tests/regressiontests/views/views.py

     
    5757    return render_to_response('debug/template_exception.html',
    5858        {'arg': except_args[int(n)]})
    5959
     60def test_extends(request):
     61    return render_to_response('debug/test_extends_error.html')
     62
     63
  • tests/regressiontests/views/urls.py

     
    110110urlpatterns += patterns('regressiontests.views.views',
    111111    url(r'view_exception/(?P<n>\d+)/$', 'view_exception', name='view_exception'),
    112112    url(r'template_exception/(?P<n>\d+)/$', 'template_exception', name='template_exception'),
     113    url(r'test_extends_error/$', 'test_extends', name='test_extends'),
     114
    113115)
  • tests/regressiontests/views/templates/debug/test_extends_error.html

     
     1{% extends "debug/broken_base.html" %}
  • tests/regressiontests/views/templates/debug/broken_base.html

    Property changes on: tests/regressiontests/views/templates/debug/test_extends_error.html
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
     
     1{% include "missing.html" %}
Back to Top