From b23d264046db1c8f58a174b9be27ee760341ba06 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 3 Mar 2017 10:52:20 -0500 Subject: [PATCH] Fixed #27887 -- Fixed URLs check crash with namespaced URLs inside non-namespaced URLs. --- django/core/checks/urls.py | 5 ++++- tests/check_framework/urls/unique_namespaces.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/django/core/checks/urls.py b/django/core/checks/urls.py index 13c7e2b08b..0f65d3f3b7 100644 --- a/django/core/checks/urls.py +++ b/django/core/checks/urls.py @@ -60,7 +60,10 @@ def _load_all_namespaces(resolver, parents=()): if getattr(url, 'namespace', None) is not None ] for pattern in url_patterns: - current = parents + (getattr(pattern, 'namespace', ()),) + namespace = getattr(pattern, 'namespace', None) + current = parents + if namespace is not None: + current += (namespace,) namespaces.extend(_load_all_namespaces(pattern, current)) return namespaces diff --git a/tests/check_framework/urls/unique_namespaces.py b/tests/check_framework/urls/unique_namespaces.py index 10d427eec9..b3f7fd70d0 100644 --- a/tests/check_framework/urls/unique_namespaces.py +++ b/tests/check_framework/urls/unique_namespaces.py @@ -15,4 +15,6 @@ urlpatterns = [ # 'nested' is included twice but namespaced by nested-1 and nested-2. url(r'^app-ns1-2/', include(nested_url_patterns, namespace='nested-1')), url(r'^app-ns1-3/', include(nested_url_patterns, namespace='nested-2')), + # namespaced URLs inside non-namespaced URLs. + url(r'^app-ns1-4/', include([url(r'^abc/', include(common_url_patterns))])), ]