diff options
| author | Chris Lamb <chris@chris-lamb.co.uk> | 2017-02-24 23:13:48 +0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-02-24 10:13:48 -0500 |
| commit | 8d4885ede578b5beef7626cd31bbd19a95bd678a (patch) | |
| tree | 516fb06c3f8b314a136b8a1657d647f619c54fff /django | |
| parent | b6fbf3e8e56b34fdc4367d582bbcb036e4aa2972 (diff) | |
Fixed #27874 -- Fixed URL namespace warning (urls.W005) for nested namespaces.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/checks/urls.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/django/core/checks/urls.py b/django/core/checks/urls.py index c39010fb7d..13c7e2b08b 100644 --- a/django/core/checks/urls.py +++ b/django/core/checks/urls.py @@ -50,17 +50,18 @@ def check_url_namespaces_unique(app_configs, **kwargs): return errors -def _load_all_namespaces(resolver): +def _load_all_namespaces(resolver, parents=()): """ Recursively load all namespaces from URL patterns. """ url_patterns = getattr(resolver, 'url_patterns', []) namespaces = [ - url.namespace for url in url_patterns + ':'.join(parents + (url.namespace,)) for url in url_patterns if getattr(url, 'namespace', None) is not None ] for pattern in url_patterns: - namespaces.extend(_load_all_namespaces(pattern)) + current = parents + (getattr(pattern, 'namespace', ()),) + namespaces.extend(_load_all_namespaces(pattern, current)) return namespaces |
