Loading django/template/defaulttags.py +4 −0 Original line number Diff line number Diff line Loading @@ -398,6 +398,10 @@ 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.") # 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, # re-raise the NoReverseMatch unless we're using the Loading docs/ref/templates/builtins.txt +10 −0 Original line number Diff line number Diff line Loading @@ -1035,6 +1035,16 @@ This will follow the normal :ref:`namespaced URL resolution strategy <topics-http-reversing-url-namespaces>`, including using any hints provided by the context as to the current application. .. warning:: Don't forget to put quotes around the function path or pattern name! .. versionchanged:: 1.5 The first paramater used not to be quoted, which was inconsistent with other template tags. Since Django 1.5, it is evaluated according to the usual rules: it can be a quoted string or a variable that will be looked up in the context. .. templatetag:: verbatim verbatim Loading tests/regressiontests/templates/tests.py +10 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,8 @@ except ImportError: # Python 2 from urlparse import urljoin from django import template from django.template import base as template_base, RequestContext, Template, Context from django.template import (base as template_base, Context, RequestContext, Template, TemplateSyntaxError) from django.core import urlresolvers from django.template import loader from django.template.loaders import app_directories, filesystem, cached Loading Loading @@ -364,6 +365,14 @@ class Templates(TestCase): with self.assertRaises(urlresolvers.NoReverseMatch): t.render(c) 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, "The syntax changed in Django 1.5, see the docs."): t.render(c) @override_settings(DEBUG=True, TEMPLATE_DEBUG=True) def test_no_wrapped_exception(self): """ Loading Loading
django/template/defaulttags.py +4 −0 Original line number Diff line number Diff line Loading @@ -398,6 +398,10 @@ 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.") # 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, # re-raise the NoReverseMatch unless we're using the Loading
docs/ref/templates/builtins.txt +10 −0 Original line number Diff line number Diff line Loading @@ -1035,6 +1035,16 @@ This will follow the normal :ref:`namespaced URL resolution strategy <topics-http-reversing-url-namespaces>`, including using any hints provided by the context as to the current application. .. warning:: Don't forget to put quotes around the function path or pattern name! .. versionchanged:: 1.5 The first paramater used not to be quoted, which was inconsistent with other template tags. Since Django 1.5, it is evaluated according to the usual rules: it can be a quoted string or a variable that will be looked up in the context. .. templatetag:: verbatim verbatim Loading
tests/regressiontests/templates/tests.py +10 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,8 @@ except ImportError: # Python 2 from urlparse import urljoin from django import template from django.template import base as template_base, RequestContext, Template, Context from django.template import (base as template_base, Context, RequestContext, Template, TemplateSyntaxError) from django.core import urlresolvers from django.template import loader from django.template.loaders import app_directories, filesystem, cached Loading Loading @@ -364,6 +365,14 @@ class Templates(TestCase): with self.assertRaises(urlresolvers.NoReverseMatch): t.render(c) 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, "The syntax changed in Django 1.5, see the docs."): t.render(c) @override_settings(DEBUG=True, TEMPLATE_DEBUG=True) def test_no_wrapped_exception(self): """ Loading