1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #12943 -- Allowed unnamed arguments to be propagated in includes

Propagated unnamed arguments as positional arguments into included
URLconfs if no named arguments are defined. Positional and keyword
arguments are never combined.
This commit is contained in:
Bas Peschier
2015-03-08 18:26:30 +01:00
committed by Tim Graham
parent 27ad12a9b8
commit f0f5212624
3 changed files with 12 additions and 1 deletions

View File

@@ -374,11 +374,19 @@ class RegexURLResolver(LocaleRegexProvider):
tried.append([pattern])
else:
if sub_match:
# Merge captured arguments in match with submatch
sub_match_dict = dict(match.groupdict(), **self.default_kwargs)
sub_match_dict.update(sub_match.kwargs)
# If there are *any* named groups, ignore all non-named groups.
# Otherwise, pass all non-named arguments as positional arguments.
sub_match_args = sub_match.args
if not sub_match_dict:
sub_match_args = match.groups() + sub_match.args
return ResolverMatch(
sub_match.func,
sub_match.args,
sub_match_args,
sub_match_dict,
sub_match.url_name,
self.app_name or sub_match.app_name,