Ticket #12950: reverse_namespaced_url.patch
File reverse_namespaced_url.patch, 1.1 KB (added by , 14 years ago) |
---|
-
django/core/urlresolvers.py
360 360 path = parts[1:] 361 361 362 362 resolved_path = [] 363 ns_pattern = '' 363 364 while path: 364 365 ns = path.pop() 365 366 … … 380 381 try: 381 382 extra, resolver = resolver.namespace_dict[ns] 382 383 resolved_path.append(ns) 383 prefix = prefix+ extra384 ns_pattern = ns_pattern + extra 384 385 except KeyError, key: 385 386 if resolved_path: 386 387 raise NoReverseMatch("%s is not a registered namespace inside '%s'" % (key, ':'.join(resolved_path))) 387 388 else: 388 389 raise NoReverseMatch("%s is not a registered namespace" % key) 389 390 391 if ns_pattern: 392 resolver = RegexURLResolver(ns_pattern, resolver.url_patterns) 393 resolver = RegexURLResolver(r'^/', [resolver]) 394 390 395 return iri_to_uri(u'%s%s' % (prefix, resolver.reverse(view, 391 396 *args, **kwargs))) 392 397