Fixed #25610 -- Reverted removal of request.current_app in {% url %} tag.
The deprecation removal in 5e450c52aa
removed too much.
This commit is contained in:
parent
23073f9644
commit
34af2bc523
|
@ -433,6 +433,9 @@ class URLNode(Node):
|
||||||
for k, v in self.kwargs.items()
|
for k, v in self.kwargs.items()
|
||||||
}
|
}
|
||||||
view_name = self.view_name.resolve(context)
|
view_name = self.view_name.resolve(context)
|
||||||
|
try:
|
||||||
|
current_app = context.request.current_app
|
||||||
|
except AttributeError:
|
||||||
try:
|
try:
|
||||||
current_app = context.request.resolver_match.namespace
|
current_app = context.request.resolver_match.namespace
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
@ -251,3 +251,23 @@ class UrlTagTests(SimpleTestCase):
|
||||||
context = RequestContext(request)
|
context = RequestContext(request)
|
||||||
output = template.render(context)
|
output = template.render(context)
|
||||||
self.assertEqual(output, '/ns2/named-client/42/')
|
self.assertEqual(output, '/ns2/named-client/42/')
|
||||||
|
|
||||||
|
@setup({'url-namespace-no-current-app': '{% url "app:named.client" 42 %}'})
|
||||||
|
def test_url_namespace_no_current_app(self):
|
||||||
|
request = RequestFactory().get('/')
|
||||||
|
request.resolver_match = resolve('/ns1/')
|
||||||
|
request.current_app = None
|
||||||
|
template = self.engine.get_template('url-namespace-no-current-app')
|
||||||
|
context = RequestContext(request)
|
||||||
|
output = template.render(context)
|
||||||
|
self.assertEqual(output, '/ns2/named-client/42/')
|
||||||
|
|
||||||
|
@setup({'url-namespace-explicit-current-app': '{% url "app:named.client" 42 %}'})
|
||||||
|
def test_url_namespace_explicit_current_app(self):
|
||||||
|
request = RequestFactory().get('/')
|
||||||
|
request.resolver_match = resolve('/ns1/')
|
||||||
|
request.current_app = 'app'
|
||||||
|
template = self.engine.get_template('url-namespace-explicit-current-app')
|
||||||
|
context = RequestContext(request)
|
||||||
|
output = template.render(context)
|
||||||
|
self.assertEqual(output, '/ns2/named-client/42/')
|
||||||
|
|
Loading…
Reference in New Issue