summaryrefslogtreecommitdiff
path: root/tests/regressiontests/urlpatterns_reverse/namespace_urls.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-07-16 16:16:13 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-07-16 16:16:13 +0000
commit8d48eaa064c88533be5082e3f45638fbd48491d8 (patch)
tree869920eb92a7e4b4248b3adf5e3f9104c4d57532 /tests/regressiontests/urlpatterns_reverse/namespace_urls.py
parent9fd19c01611e5ed1ed64bbeb462ab96499d72a6c (diff)
Fixed #10061 -- Added namespacing for named URLs - most importantly, for the admin site, where the absence of this facility was causing problems. Thanks to the many people who contributed to and helped review this patch.
This change is backwards incompatible for anyone that is using the named URLs introduced in [9739]. Any usage of the old admin_XXX names need to be modified to use the new namespaced format; in many cases this will be as simple as a search & replace for "admin_" -> "admin:". See the docs for more details on the new URL names, and the namespace resolution strategy. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11250 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/urlpatterns_reverse/namespace_urls.py')
-rw-r--r--tests/regressiontests/urlpatterns_reverse/namespace_urls.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/regressiontests/urlpatterns_reverse/namespace_urls.py b/tests/regressiontests/urlpatterns_reverse/namespace_urls.py
new file mode 100644
index 0000000000..27cc7f7a22
--- /dev/null
+++ b/tests/regressiontests/urlpatterns_reverse/namespace_urls.py
@@ -0,0 +1,38 @@
+from django.conf.urls.defaults import *
+
+class URLObject(object):
+ def __init__(self, app_name, namespace):
+ self.app_name = app_name
+ self.namespace = namespace
+
+ def urls(self):
+ return patterns('',
+ url(r'^inner/$', 'empty_view', name='urlobject-view'),
+ url(r'^inner/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='urlobject-view'),
+ ), self.app_name, self.namespace
+ urls = property(urls)
+
+testobj1 = URLObject('testapp', 'test-ns1')
+testobj2 = URLObject('testapp', 'test-ns2')
+default_testobj = URLObject('testapp', 'testapp')
+
+otherobj1 = URLObject('nodefault', 'other-ns1')
+otherobj2 = URLObject('nodefault', 'other-ns2')
+
+urlpatterns = patterns('regressiontests.urlpatterns_reverse.views',
+ url(r'^normal/$', 'empty_view', name='normal-view'),
+ url(r'^normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='normal-view'),
+
+ (r'^test1/', include(testobj1.urls)),
+ (r'^test2/', include(testobj2.urls)),
+ (r'^default/', include(default_testobj.urls)),
+
+ (r'^other1/', include(otherobj1.urls)),
+ (r'^other2/', include(otherobj2.urls)),
+
+ (r'^ns-included1/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns1')),
+ (r'^ns-included2/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns2')),
+
+ (r'^included/', include('regressiontests.urlpatterns_reverse.included_namespace_urls')),
+
+)