Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1579 from ianawilson/ticket_21058

[1.6.x] Fixed #21058 -- Fixed debug view blowing up when no template is provided to the template rendering functions.

Assistance on this commit from @jambonrose.

Backport of 122020f from master.
  • Loading branch information...
commit b917458f4752e98dc7866261f40e296de3701130 1 parent 2ab2d0f
Russell Keith-Magee freakboy3742 authored
2  AUTHORS
View
@@ -465,6 +465,7 @@ answer newbie questions, and generally made Django that much better:
phil@produxion.net
phil.h.smith@gmail.com
Gustavo Picon
+ Andrew Pinkham <http://AndrewsForge.com>
Travis Pinney
Michael Placentra II <someone@michaelplacentra2.net>
plisk
@@ -626,6 +627,7 @@ answer newbie questions, and generally made Django that much better:
Derek Willis <http://blog.thescoop.org/>
Rachel Willmer <http://www.willmer.com/kb/>
Jakub Wilk <ubanus@users.sf.net>
+ Ian A Wilson <http://ianawilson.com>
Jakub Wiśniowski <restless.being@gmail.com>
Maciej Wiśniowski <pigletto@gmail.com>
wojtek
4 django/views/debug.py
View
@@ -233,6 +233,10 @@ def get_traceback_data(self):
from django.template.loader import template_source_loaders
self.template_does_not_exist = True
self.loader_debug_info = []
+ # If the template_source_loaders haven't been populated yet, you need
+ # to provide an empty list for this for loop to not fail.
+ if template_source_loaders is None:
+ template_source_loaders = []
for loader in template_source_loaders:
try:
source_list_func = loader.get_template_sources
7 tests/view_tests/tests/test_debug.py
View
@@ -12,6 +12,7 @@
from django.core import mail
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.urlresolvers import reverse
+from django.template.base import TemplateDoesNotExist
from django.test import TestCase, RequestFactory
from django.test.utils import (override_settings, setup_test_template_loader,
restore_template_loaders)
@@ -113,6 +114,12 @@ def test_template_loader_postmortem_notafile(self):
finally:
shutil.rmtree(template_path)
+ def test_no_template_source_loaders(self):
+ """
+ Make sure if you don't specify a template, the debug view doesn't blow up.
+ """
+ self.assertRaises(TemplateDoesNotExist, self.client.get, '/render_no_template/')
+
class ExceptionReporterTests(TestCase):
rf = RequestFactory()
1  tests/view_tests/urls.py
View
@@ -69,4 +69,5 @@
url(r'view_exception/(?P<n>\d+)/$', 'view_exception', name='view_exception'),
url(r'template_exception/(?P<n>\d+)/$', 'template_exception', name='template_exception'),
url(r'^raises_template_does_not_exist/(?P<path>.+)$', 'raises_template_does_not_exist', name='raises_template_does_not_exist'),
+ url(r'^render_no_template/$', 'render_no_template', name='render_no_template'),
)
5 tests/view_tests/views.py
View
@@ -123,6 +123,11 @@ def raises_template_does_not_exist(request, path='i_dont_exist.html'):
except TemplateDoesNotExist:
return technical_500_response(request, *sys.exc_info())
+def render_no_template(request):
+ # If we do not specify a template, we need to make sure the debug
+ # view doesn't blow up.
+ return render(request, [], {})
+
def send_log(request, exc_info):
logger = getLogger('django.request')
# The default logging config has a logging filter to ensure admin emails are
Please sign in to comment.
Something went wrong with that request. Please try again.