diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
index b634b56..e31d4fa 100644
a
|
b
|
class RegexURLPattern(LocaleRegexProvider):
|
198 | 198 | # If there are any named groups, use those as kwargs, ignoring |
199 | 199 | # non-named groups. Otherwise, pass all non-named arguments as |
200 | 200 | # positional arguments. |
201 | | kwargs = match.groupdict() |
202 | | if kwargs: |
| 201 | match_kwargs = match.groupdict() |
| 202 | if match_kwargs: |
203 | 203 | args = () |
204 | 204 | else: |
205 | 205 | args = match.groups() |
206 | 206 | # In both cases, pass any extra_kwargs as **kwargs. |
207 | | kwargs.update(self.default_args) |
| 207 | kwargs = self.default_args.copy() |
| 208 | kwargs.update(match_kwargs) |
208 | 209 | |
209 | 210 | return ResolverMatch(self.callback, args, kwargs, self.name) |
210 | 211 | |
… |
… |
class RegexURLResolver(LocaleRegexProvider):
|
374 | 375 | continue |
375 | 376 | matches = True |
376 | 377 | for k, v in defaults.items(): |
| 378 | if k in params: |
| 379 | continue |
377 | 380 | if kwargs.get(k, v) != v: |
378 | 381 | matches = False |
379 | 382 | break |
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index f3e27ae..02d9ac9 100644
a
|
b
|
options to views.
|
587 | 587 | |
588 | 588 | It's possible to have a URL pattern which captures named keyword arguments, |
589 | 589 | and also passes arguments with the same names in its dictionary of extra |
590 | | arguments. When this happens, the arguments in the dictionary will be used |
591 | | instead of the arguments captured in the URL. |
| 590 | arguments. When this happens, the arguments captured in the url will be |
| 591 | used instead of the arguments in the dictionary. |
592 | 592 | |
593 | 593 | Passing extra options to ``include()`` |
594 | 594 | -------------------------------------- |
diff --git a/tests/regressiontests/i18n/patterns/tests.py b/tests/regressiontests/i18n/patterns/tests.py
index 1cc4520..5a8e868 100644
a
|
b
|
import os
|
4 | 4 | import warnings |
5 | 5 | |
6 | 6 | from django.core.exceptions import ImproperlyConfigured |
7 | | from django.core.urlresolvers import reverse, clear_url_caches |
| 7 | from django.core.urlresolvers import reverse, resolve, clear_url_caches |
8 | 8 | from django.test import TestCase |
9 | 9 | from django.test.utils import override_settings |
10 | 10 | from django.template import Template, Context |
… |
… |
class URLTagTests(URLTestCaseBase):
|
306 | 306 | {% language 'pt-br' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}""") |
307 | 307 | self.assertEqual(tpl.render(Context({})).strip().split(), |
308 | 308 | [u'/vertaald/apo/', u'/traduzidos/apo/']) |
| 309 | |
| 310 | |
| 311 | class URLExampleTests(URLTestCaseBase): |
| 312 | def test_demo(self): |
| 313 | # User accesses an english url. |
| 314 | with translation.override('en'): |
| 315 | match = resolve('/translated/apo/') |
| 316 | # Now we want provide links to the same page in other languages |
| 317 | links = [] |
| 318 | langs = ['nl', 'pt-br'] |
| 319 | for lang in langs: |
| 320 | with translation.override(lang): |
| 321 | links.append(reverse(match.url_name, args=match.args, kwargs=match.match_kwargs)) |
| 322 | self.assertEqual(links, [u'/vertaald/apo/', u'/traduzidos/apo/']) |
| 323 | # Now we can offer the user links to the other pages |
| 324 | # print "View the page in: ", |
| 325 | # for lang, link in zip(langs, links): |
| 326 | # print "<a href='%s'>%s</a> % (link, lang), |
diff --git a/tests/regressiontests/i18n/patterns/urls/default.py b/tests/regressiontests/i18n/patterns/urls/default.py
index f117502..aac68ff 100644
a
|
b
|
view = TemplateView.as_view(template_name='dummy.html')
|
9 | 9 | urlpatterns = patterns('', |
10 | 10 | url(r'^not-prefixed/$', view, name='not-prefixed'), |
11 | 11 | url(_(r'^translated/$'), view, name='no-prefix-translated'), |
12 | | url(_(r'^translated/(?P<slug>[\w-]+)/$'), view, name='no-prefix-translated-slug'), |
| 12 | url(_(r'^translated/(?P<slug>[\w-]+)/$'), view, {'extra': True}, |
| 13 | name='no-prefix-translated-slug'), |
13 | 14 | ) |
14 | 15 | |
15 | 16 | urlpatterns += i18n_patterns('', |
16 | 17 | url(r'^prefixed/$', view, name='prefixed'), |
17 | 18 | url(_(r'^users/$'), view, name='users'), |
18 | | url(_(r'^account/'), include('regressiontests.i18n.patterns.urls.namespace', namespace='account')), |
| 19 | url(_(r'^account/'), include('regressiontests.i18n.patterns.urls.namespace', |
| 20 | namespace='account')), |
19 | 21 | ) |
diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
index a1c9244..f3c40b9 100644
a
|
b
|
class ErroneousViewTests(TestCase):
|
511 | 511 | self.assertRaises(ViewDoesNotExist, self.client.get, '/missing_outer/') |
512 | 512 | self.assertRaises(ViewDoesNotExist, self.client.get, '/uncallable/') |
513 | 513 | |
| 514 | |
| 515 | class TestRereverse(TestCase): |
| 516 | urls = 'regressiontests.urlpatterns_reverse.urls' |
| 517 | |
| 518 | def test_rereverse(self): |
| 519 | match = resolve('/rereverse/12/') |
| 520 | self.assertEqual(reverse(match.url_name, args=match.args, kwargs=match.kwargs), '/rereverse/12/') |
| 521 | match = resolve('/rereverse-overridden/12/url/') |
| 522 | self.assertEqual(reverse(match.url_name, args=match.args, kwargs=match.kwargs), '/rereverse-overridden/12/url/') |
diff --git a/tests/regressiontests/urlpatterns_reverse/urls.py b/tests/regressiontests/urlpatterns_reverse/urls.py
index 1d4ae73..fee6546 100644
a
|
b
|
urlpatterns = patterns('',
|
41 | 41 | url(r'^windows_path/(?P<drive_name>[A-Z]):\\(?P<path>.+)/$', empty_view, |
42 | 42 | name="windows"), |
43 | 43 | url(r'^special_chars/(.+)/$', empty_view, name="special"), |
| 44 | url(r'^rereverse/(?P<arg>\d+)/$', empty_view, {'extra': True}, |
| 45 | name='rereverse'), |
| 46 | url(r'^rereverse-overridden/(?P<arg>\d+)/(?P<overridden>\w+)/$', |
| 47 | empty_view, {'extra': True, 'overridden': 'default'}, |
| 48 | name='rereverse-overridden'), |
44 | 49 | url(r'^(?P<name>.+)/\d+/$', empty_view, name="mixed"), |
45 | 50 | url(r'^repeats/a{1,2}/$', empty_view, name="repeats"), |
46 | 51 | url(r'^repeats/a{2,4}/$', empty_view, name="repeats2"), |