Permalink
Browse files

Change exception type to reduce confusion.

TemplateSyntaxError is expected at compile time, not at run time.

Refs #19280.
  • Loading branch information...
1 parent f89901d commit 7644800070bf3027fb10cd45ea9f0e36e8334fc1 @aaugustin aaugustin committed Nov 25, 2012
Showing with 4 additions and 4 deletions.
  1. +2 −2 django/template/defaulttags.py
  2. +2 −2 tests/regressiontests/templates/tests.py
@@ -399,8 +399,8 @@ def render(self, context):
view_name = self.view_name.resolve(context)
if not view_name:
- raise TemplateSyntaxError("'url' takes requires a non-empty first"
- " argument. The syntax changed in Django 1.5, see the docs.")
+ raise NoReverseMatch("'url' requires a non-empty first argument. "
+ "The syntax changed in Django 1.5, see the docs.")
# Try to look up the URL twice: once given the view name, and again
# relative to what we guess is the "main" app. If they both fail,
@@ -20,7 +20,7 @@
from django import template
from django.template import (base as template_base, Context, RequestContext,
- Template, TemplateSyntaxError)
+ Template)
from django.core import urlresolvers
from django.template import loader
from django.template.loaders import app_directories, filesystem, cached
@@ -369,7 +369,7 @@ def test_url_explicit_exception_for_old_syntax(self):
# Regression test for #19280
t = Template('{% url path.to.view %}') # not quoted = old syntax
c = Context()
- with self.assertRaisesRegexp(TemplateSyntaxError,
+ with self.assertRaisesRegexp(urlresolvers.NoReverseMatch,
"The syntax changed in Django 1.5, see the docs."):
t.render(c)

0 comments on commit 7644800

Please sign in to comment.