diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
index eef8349..a35287e 100644
a
|
b
|
class RegexURLResolver(object):
|
302 | 302 | def resolve500(self): |
303 | 303 | return self._resolve_special('500') |
304 | 304 | |
305 | | def reverse(self, lookup_view, *args, **kwargs): |
306 | | prefix = kwargs.pop('__DJANGO_REVERSE_PREFIX','') |
| 305 | def reverse(self, lookup_view, *args, **kwargs): |
307 | 306 | if args and kwargs: |
308 | 307 | raise ValueError("Don't mix *args and **kwargs in call to reverse()!") |
309 | 308 | try: |
… |
… |
class RegexURLResolver(object):
|
311 | 310 | except (ImportError, AttributeError), e: |
312 | 311 | raise NoReverseMatch("Error importing '%s': %s." % (lookup_view, e)) |
313 | 312 | possibilities = self.reverse_dict.getlist(lookup_view) |
314 | | prefix_norm, prefix_args = normalize(prefix)[0] |
315 | 313 | for possibility, pattern in possibilities: |
316 | 314 | for result, params in possibility: |
317 | 315 | if args: |
318 | | if len(args) != len(params) + len(prefix_args): |
| 316 | if len(args) != len(params): |
319 | 317 | continue |
320 | 318 | unicode_args = [force_unicode(val) for val in args] |
321 | | candidate = (prefix_norm + result) % dict(zip(params, unicode_args)) |
| 319 | candidate = result % dict(zip(params, unicode_args)) |
322 | 320 | else: |
323 | | if set(kwargs.keys()) != (set(params)|set(prefix_args)): |
| 321 | if set(kwargs.keys()) != set(params): |
324 | 322 | continue |
325 | 323 | unicode_kwargs = dict([(k, force_unicode(v)) for (k, v) in kwargs.items()]) |
326 | | candidate = (prefix_norm + result) % unicode_kwargs |
327 | | if re.search(u'^%s%s' % (prefix, pattern), candidate, re.UNICODE): |
| 324 | candidate = result % unicode_kwargs |
| 325 | if re.search(u'^%s' % pattern, candidate, re.UNICODE): |
328 | 326 | return candidate |
329 | 327 | # lookup_view can be URL label, or dotted path, or callable, Any of |
330 | 328 | # these can be passed in at the top, but callables are not friendly in |
… |
… |
def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, current
|
388 | 386 | raise NoReverseMatch("%s is not a registered namespace inside '%s'" % (key, ':'.join(resolved_path))) |
389 | 387 | else: |
390 | 388 | raise NoReverseMatch("%s is not a registered namespace" % key) |
391 | | kwargs['__DJANGO_REVERSE_PREFIX'] = prefix |
392 | | return iri_to_uri(resolver.reverse(view, *args, **kwargs)) |
| 389 | |
| 390 | return iri_to_uri(u'%s%s' % (prefix, resolver.reverse(view, |
| 391 | *args, **kwargs))) |
393 | 392 | |
394 | 393 | def clear_url_caches(): |
395 | 394 | global _resolver_cache |
diff --git a/tests/regressiontests/urlpatterns_reverse/namespace_urls.py b/tests/regressiontests/urlpatterns_reverse/namespace_urls.py
index e3094e6..3d34049 100644
a
|
b
|
urlpatterns = patterns('regressiontests.urlpatterns_reverse.views',
|
37 | 37 | (r'^default/', include(default_testobj.urls)), |
38 | 38 | |
39 | 39 | (r'^other1/', include(otherobj1.urls)), |
40 | | (r'^other[246]/', include(otherobj2.urls)), |
| 40 | (r'^other2/', include(otherobj2.urls)), |
41 | 41 | |
42 | | (r'^ns-included[135]/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns1')), |
| 42 | (r'^ns-included1/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns1')), |
43 | 43 | (r'^ns-included2/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns2')), |
44 | 44 | |
45 | 45 | (r'^included/', include('regressiontests.urlpatterns_reverse.included_namespace_urls')), |