Skip to content

Commit

Permalink
[1.5.x] Change exception type to reduce confusion.
Browse files Browse the repository at this point in the history
TemplateSyntaxError is expected at compile time, not at run time.

Refs #19280.

Backport of 7644800.
  • Loading branch information
aaugustin committed Nov 25, 2012
1 parent 7223161 commit 37c54c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions django/template/defaulttags.py
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/regressiontests/templates/tests.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 37c54c2

Please sign in to comment.