Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #18169 -- NoReverseMatch not silenced if from block.super

  • Loading branch information...
commit 369b6fab25b55ceb363ba2a8cb7e0f1a88ef8f8d 1 parent 8490937
Anssi Kääriäinen authored May 30, 2013
3  django/core/urlresolvers.py
@@ -75,8 +75,7 @@ class Resolver404(Http404):
75 75
     pass
76 76
 
77 77
 class NoReverseMatch(Exception):
78  
-    # Don't make this raise an error when used in a template.
79  
-    silent_variable_failure = True
  78
+    pass
80 79
 
81 80
 def get_callable(lookup_view, can_fail=False):
82 81
     """
6  docs/releases/1.6.txt
@@ -616,6 +616,12 @@ Miscellaneous
616 616
   stored as ``null``. Previously, storing a ``blank`` value in a field which
617 617
   did not allow ``null`` would cause a database exception at runtime.
618 618
 
  619
+* If a :class:`~django.core.urlresolvers.NoReverseMatch` exception is risen
  620
+  from a method when rendering a template it is not silenced. For example
  621
+  {{ obj.view_href }} will cause template rendering to fail if view_href()
  622
+  raises NoReverseMatch. There is no change to {% url %} tag, it causes
  623
+  template rendering to fail like always when NoReverseMatch is risen.
  624
+
619 625
 Features deprecated in 1.6
620 626
 ==========================
621 627
 
3  tests/template_tests/templates/included_base.html
... ...
@@ -0,0 +1,3 @@
  1
+{% block content %}
  2
+  {% block error_here %}{% endblock %}
  3
+{% endblock %}
11  tests/template_tests/templates/included_content.html
... ...
@@ -0,0 +1,11 @@
  1
+{% extends "included_base.html" %}
  2
+
  3
+{% block content %}
  4
+  content
  5
+  {{ block.super }}
  6
+{% endblock %}
  7
+
  8
+{% block error_here %}
  9
+  error here
  10
+  {% url "non_existing_url" %}
  11
+{% endblock %}
9  tests/template_tests/tests.py
@@ -444,6 +444,15 @@ def test_ifchanged_render_once(self):
444 444
         output = template.render(Context({}))
445 445
         self.assertEqual(output, '1st time')
446 446
 
  447
+    def test_super_errors(self):
  448
+        """
  449
+        Test behavior of the raise errors into included blocks.
  450
+        See #18169
  451
+        """
  452
+        t = loader.get_template('included_content.html')
  453
+        with self.assertRaises(urlresolvers.NoReverseMatch):
  454
+            t.render(Context({}))
  455
+
447 456
     def test_templates(self):
448 457
         template_tests = self.get_template_tests()
449 458
         filter_tests = filters.get_filter_tests()

0 notes on commit 369b6fa

Please sign in to comment.
Something went wrong with that request. Please try again.