Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.5.x] Fixed #19392 -- Improved error for old-style url tags with da…

…shes.

Thanks dloewenherz for the report.

Backport of 4951932 from master.
  • Loading branch information...
commit d6bad2e9ea77ce48ee5755a7b44682d892bfa3d4 1 parent fce7794
@aaugustin aaugustin authored
View
7 django/template/defaulttags.py
@@ -1262,7 +1262,12 @@ def url(parser, token):
if len(bits) < 2:
raise TemplateSyntaxError("'%s' takes at least one argument"
" (path to a view)" % bits[0])
- viewname = parser.compile_filter(bits[1])
+ try:
+ viewname = parser.compile_filter(bits[1])
+ except TemplateSyntaxError as exc:
+ exc.args = (exc.args[0] + ". "
+ "The syntax of 'url' changed in Django 1.5, see the docs."),
+ raise
args = []
kwargs = {}
asvar = None
View
8 tests/regressiontests/templates/tests.py
@@ -366,7 +366,7 @@ def test_url_reverse_no_settings_module(self):
with self.assertRaises(urlresolvers.NoReverseMatch):
t.render(c)
- def test_url_explicit_exception_for_old_syntax(self):
+ def test_url_explicit_exception_for_old_syntax_at_run_time(self):
# Regression test for #19280
t = Template('{% url path.to.view %}') # not quoted = old syntax
c = Context()
@@ -374,6 +374,12 @@ def test_url_explicit_exception_for_old_syntax(self):
"The syntax changed in Django 1.5, see the docs."):
t.render(c)
+ def test_url_explicit_exception_for_old_syntax_at_compile_time(self):
+ # Regression test for #19392
+ with self.assertRaisesRegexp(template.TemplateSyntaxError,
+ "The syntax of 'url' changed in Django 1.5, see the docs."):
+ t = Template('{% url my-view %}') # not a variable = old syntax
+
@override_settings(DEBUG=True, TEMPLATE_DEBUG=True)
def test_no_wrapped_exception(self):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.