diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-11-25 19:51:42 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-11-25 19:51:42 +0100 |
| commit | 7644800070bf3027fb10cd45ea9f0e36e8334fc1 (patch) | |
| tree | 77b547cdbab274b72e258a2c2a74a9afa6e03167 | |
| parent | f89901dc0525f3ea1ca023aef4fd0862514bf550 (diff) | |
Change exception type to reduce confusion.
TemplateSyntaxError is expected at compile time, not at run time.
Refs #19280.
| -rw-r--r-- | django/template/defaulttags.py | 4 | ||||
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 1f4627e32a..45f4c1dbb1 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -399,8 +399,8 @@ class URLNode(Node): 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, diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 6d55ebbc17..b46e38cc15 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -20,7 +20,7 @@ except ImportError: # Python 2 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 @@ class Templates(TestCase): # 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) |
