summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_views/customadmin.py
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-01-14 20:22:25 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-01-14 20:22:25 +0000
commit1f84630c87f8032b0167e6db41acaf50ab710879 (patch)
tree97b7ddd8adb847b0a3461b75cb0e5b215c7d7db0 /tests/regressiontests/admin_views/customadmin.py
parent6c4e5f0f0e9469d7e56d824d2b153cd25fb443ee (diff)
Fixed #6470: made the admin use a URL resolver.
This *is* backwards compatible, but `admin.site.root()` has been deprecated. The new style is `('^admin/', include(admin.site.urls))`; users will need to update their code to take advantage of the new customizable admin URLs. Thanks to Alex Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9739 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_views/customadmin.py')
-rw-r--r--tests/regressiontests/admin_views/customadmin.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_views/customadmin.py b/tests/regressiontests/admin_views/customadmin.py
new file mode 100644
index 0000000000..c812eab98b
--- /dev/null
+++ b/tests/regressiontests/admin_views/customadmin.py
@@ -0,0 +1,30 @@
+"""
+A second, custom AdminSite -- see tests.CustomAdminSiteTests.
+"""
+from django.conf.urls.defaults import patterns
+from django.contrib import admin
+from django.http import HttpResponse
+
+import models
+
+class Admin2(admin.AdminSite):
+ login_template = 'custom_admin/login.html'
+ index_template = 'custom_admin/index.html'
+
+ # A custom index view.
+ def index(self, request, extra_context=None):
+ return super(Admin2, self).index(request, {'foo': '*bar*'})
+
+ def get_urls(self):
+ return patterns('',
+ (r'^my_view/$', self.admin_view(self.my_view)),
+ ) + super(Admin2, self).get_urls()
+
+ def my_view(self, request):
+ return HttpResponse("Django is a magical pony!")
+
+site = Admin2(name="admin2")
+
+site.register(models.Article, models.ArticleAdmin)
+site.register(models.Section, inlines=[models.ArticleInline])
+site.register(models.Thing, models.ThingAdmin)