2009-01-15 04:22:25 +08:00
|
|
|
"""
|
|
|
|
A second, custom AdminSite -- see tests.CustomAdminSiteTests.
|
|
|
|
"""
|
2011-09-12 06:36:16 +08:00
|
|
|
from django.conf.urls import patterns
|
2009-01-15 04:22:25 +08:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
2010-12-02 08:44:35 +08:00
|
|
|
import models, forms
|
2009-01-15 04:22:25 +08:00
|
|
|
|
|
|
|
class Admin2(admin.AdminSite):
|
2010-12-02 08:44:35 +08:00
|
|
|
login_form = forms.CustomAdminAuthenticationForm
|
2009-01-15 04:22:25 +08:00
|
|
|
login_template = 'custom_admin/login.html'
|
2010-01-13 07:34:46 +08:00
|
|
|
logout_template = 'custom_admin/logout.html'
|
2009-01-15 04:22:25 +08:00
|
|
|
index_template = 'custom_admin/index.html'
|
2010-01-13 07:34:46 +08:00
|
|
|
password_change_template = 'custom_admin/password_change_form.html'
|
|
|
|
password_change_done_template = 'custom_admin/password_change_done.html'
|
2009-07-17 00:16:13 +08:00
|
|
|
|
2009-01-15 04:22:25 +08:00
|
|
|
# A custom index view.
|
|
|
|
def index(self, request, extra_context=None):
|
|
|
|
return super(Admin2, self).index(request, {'foo': '*bar*'})
|
2009-07-17 00:16:13 +08:00
|
|
|
|
2009-01-15 04:22:25 +08:00
|
|
|
def get_urls(self):
|
|
|
|
return patterns('',
|
|
|
|
(r'^my_view/$', self.admin_view(self.my_view)),
|
|
|
|
) + super(Admin2, self).get_urls()
|
2009-07-17 00:16:13 +08:00
|
|
|
|
2009-01-15 04:22:25 +08:00
|
|
|
def my_view(self, request):
|
|
|
|
return HttpResponse("Django is a magical pony!")
|
2009-07-17 00:16:13 +08:00
|
|
|
|
2009-01-15 04:22:25 +08:00
|
|
|
site = Admin2(name="admin2")
|
|
|
|
|
|
|
|
site.register(models.Article, models.ArticleAdmin)
|
|
|
|
site.register(models.Section, inlines=[models.ArticleInline])
|
|
|
|
site.register(models.Thing, models.ThingAdmin)
|
2009-04-01 22:14:20 +08:00
|
|
|
site.register(models.Fabric, models.FabricAdmin)
|
2010-11-22 03:29:15 +08:00
|
|
|
site.register(models.ChapterXtra1, models.ChapterXtra1Admin)
|