我想在 Django 项目中有 2 个独立的管理站点。
首先是默认管理员,其次是“coursemanager”我在 AdminSite 的帮助下添加了以下代码
文件路径“cms/courses/admin.py”
from courses.models import *
from django.contrib import admin
from django.contrib.admin.sites import AdminSite
from django.contrib.auth.models import User, Group
from django.contrib.auth.admin import UserAdmin, GroupAdmin
class CourseManager(AdminSite):
name = 'CourseManager'
course_manager = CourseManager()
class CityAdmin(admin.ModelAdmin):
list_display = ['__unicode__', 'status',]
list_filter = ['status',]
search_fields = ['title',]
course_manager.register(City, CityAdmin)
“cms/cms/urls.py”
from courses.admin import course_manager
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'coursemanager/', include(course_manager.urls)),
)
但是当我添加这个http://domain.local/coursemanager/和http://domain.local/admin/两个面板都工作但在http://domain.local/coursemanger/列表注册城市模块但没有显示添加或更改链接。事件我试图从 url 访问链接但不工作。我正在以超级用户身份检查它,并且我可以访问所有模块。但是当我像下面这样更改代码时
“cms/cms/urls.py”
from courses.admin import course_manager
urlpatterns = patterns('',
url(r'coursemanager/', include(course_manager.urls)),
url(r'^admin/', include(admin.site.urls)),
)
然后http://domain.local/coursemanager/正常工作,http://domain.local/admin面板仅列出所有注册管理员,但不显示添加/更改链接。