Ticket #13051: ns.diff

File ns.diff, 2.5 KB (added by Florian Apolloner, 15 years ago)
  • django/core/urlresolvers.py

    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index 3bb2c1c..fb21808 100644
    a b def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, current  
    338338                elif ns not in app_list:
    339339                    # The name isn't shared by one of the instances (i.e., the default)
    340340                    # so just pick the first instance as the default.
    341                     ns = app_list[0]
     341                    # We actually use the last as the list is reversed!
     342                    ns = app_list[-1]
    342343            except KeyError:
    343344                pass
    344345
  • tests/regressiontests/urlpatterns_reverse/tests.py

    diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
    index d5f3ec9..e6dc262 100644
    a b class NamespaceTests(TestCase):  
    242242
    243243    def test_app_lookup_object_without_default(self):
    244244        "An application namespace without a default is sensitive to the 'current' app can be used for lookup"
    245         self.assertEquals('/other2/inner/', reverse('nodefault:urlobject-view'))
    246         self.assertEquals('/other2/inner/37/42/', reverse('nodefault:urlobject-view', args=[37,42]))
    247         self.assertEquals('/other2/inner/42/37/', reverse('nodefault:urlobject-view', kwargs={'arg1':42, 'arg2':37}))
     245        self.assertEquals('/other1/inner/', reverse('nodefault:urlobject-view'))
     246        self.assertEquals('/other1/inner/37/42/', reverse('nodefault:urlobject-view', args=[37,42]))
     247        self.assertEquals('/other1/inner/42/37/', reverse('nodefault:urlobject-view', kwargs={'arg1':42, 'arg2':37}))
    248248
    249         self.assertEquals('/other1/inner/', reverse('nodefault:urlobject-view', current_app='other-ns1'))
    250         self.assertEquals('/other1/inner/37/42/', reverse('nodefault:urlobject-view', args=[37,42], current_app='other-ns1'))
    251         self.assertEquals('/other1/inner/42/37/', reverse('nodefault:urlobject-view', kwargs={'arg1':42, 'arg2':37}, current_app='other-ns1'))
     249        self.assertEquals('/other2/inner/', reverse('nodefault:urlobject-view', current_app='other-ns2'))
     250        self.assertEquals('/other2/inner/37/42/', reverse('nodefault:urlobject-view', args=[37,42], current_app='other-ns2'))
     251        self.assertEquals('/other2/inner/42/37/', reverse('nodefault:urlobject-view', kwargs={'arg1':42, 'arg2':37}, current_app='other-ns2'))
    252252
    253253class RequestURLconfTests(TestCase):
    254254    def setUp(self):
Back to Top