mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #29775 -- Fixed URL converters in a nested namespaced path.
When using include() without namespaces of some urlpatterns that have an include() with namespace, the converters of the parent include() weren't being used to convert the arguments of reverse().
This commit is contained in:
parent
b8b1d8cad6
commit
b0b4aac555
1
AUTHORS
1
AUTHORS
@ -255,6 +255,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
enlight
|
enlight
|
||||||
Enrico <rico.bl@gmail.com>
|
Enrico <rico.bl@gmail.com>
|
||||||
Eric Boersma <eric.boersma@gmail.com>
|
Eric Boersma <eric.boersma@gmail.com>
|
||||||
|
Eric Brandwein <brandweineric@gmail.com>
|
||||||
Eric Floehr <eric@intellovations.com>
|
Eric Floehr <eric@intellovations.com>
|
||||||
Eric Florenzano <floguy@gmail.com>
|
Eric Florenzano <floguy@gmail.com>
|
||||||
Eric Holscher <http://ericholscher.com>
|
Eric Holscher <http://ericholscher.com>
|
||||||
|
@ -469,6 +469,8 @@ class URLResolver:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
for namespace, (prefix, sub_pattern) in url_pattern.namespace_dict.items():
|
for namespace, (prefix, sub_pattern) in url_pattern.namespace_dict.items():
|
||||||
|
current_converters = url_pattern.pattern.converters
|
||||||
|
sub_pattern.pattern.converters.update(current_converters)
|
||||||
namespaces[namespace] = (p_pattern + prefix, sub_pattern)
|
namespaces[namespace] = (p_pattern + prefix, sub_pattern)
|
||||||
for app_name, namespace_list in url_pattern.app_dict.items():
|
for app_name, namespace_list in url_pattern.app_dict.items():
|
||||||
apps.setdefault(app_name, []).extend(namespace_list)
|
apps.setdefault(app_name, []).extend(namespace_list)
|
||||||
|
@ -4,8 +4,16 @@ from . import converters, views
|
|||||||
|
|
||||||
register_converter(converters.Base64Converter, 'base64')
|
register_converter(converters.Base64Converter, 'base64')
|
||||||
|
|
||||||
|
subsubpatterns = [
|
||||||
|
path('<base64:last_value>/', views.empty_view, name='subsubpattern-base64'),
|
||||||
|
]
|
||||||
|
|
||||||
subpatterns = [
|
subpatterns = [
|
||||||
path('<base64:value>/', views.empty_view, name='subpattern-base64'),
|
path('<base64:value>/', views.empty_view, name='subpattern-base64'),
|
||||||
|
path(
|
||||||
|
'<base64:value>/',
|
||||||
|
include((subsubpatterns, 'second-layer-namespaced-base64'), 'instance-ns-base64')
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -70,6 +70,13 @@ class SimplifiedURLTests(SimpleTestCase):
|
|||||||
url = reverse(url_name, kwargs=kwargs)
|
url = reverse(url_name, kwargs=kwargs)
|
||||||
self.assertEqual(url, expected)
|
self.assertEqual(url, expected)
|
||||||
|
|
||||||
|
@override_settings(ROOT_URLCONF='urlpatterns.path_base64_urls')
|
||||||
|
def test_converter_reverse_with_second_layer_instance_namespace(self):
|
||||||
|
kwargs = included_kwargs.copy()
|
||||||
|
kwargs['last_value'] = b'world'
|
||||||
|
url = reverse('instance-ns-base64:subsubpattern-base64', kwargs=kwargs)
|
||||||
|
self.assertEqual(url, '/base64/aGVsbG8=/subpatterns/d29ybGQ=/d29ybGQ=/')
|
||||||
|
|
||||||
def test_path_inclusion_is_matchable(self):
|
def test_path_inclusion_is_matchable(self):
|
||||||
match = resolve('/included_urls/extra/something/')
|
match = resolve('/included_urls/extra/something/')
|
||||||
self.assertEqual(match.url_name, 'inner-extra')
|
self.assertEqual(match.url_name, 'inner-extra')
|
||||||
|
Loading…
Reference in New Issue
Block a user