我想为我的项目使用两个管理站点。每个都有grappelli仪表板。我执行了这个命令:
python manage.py customdashboard dashboard.py
python manage.py customdashboard dashboard.py
两次(一次在项目/项目中,第二次在项目/应用程序中)
#file system
project
project
dashboard.py
urls.py
app
dashboard.py
admin.py
#settings.py
GRAPPELLI_INDEX_DASHBOARD = {
'django.contrib.admin.site': 'project.dashboard.CustomIndexDashboard',
'app.admin.operator_site': 'app.dashboard.CustomIndexDashboard',
}
#urls.py
from django.conf.urls import patterns, url, include
from django.contrib import admin
from app.admin import admin_site
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^myadmin/', include(operator_site.urls)),
url(r'^grappelli/', include('grappelli.urls')),
)
#app/admin.py
from django.contrib.admin import AdminSite
class MyAdminSite(AdminSite):
pass
admin_site = MyAdminSite()
问题是当我去/ admin /一切正常时,但是当我去/ myadmin /时,我有了ValueError
仪表板匹配“{'app.admin.operator_site':'app.dashboard.CustomIndexDashboard','django.contrib.admin.site':'project.dashboard.CustomIndexDashboard'}”not found
完整错误跟踪:http://pastebin.com/w8W2eRPd
问题出在哪里?
答案 0 :(得分:1)
好的,我发现了。在制作实例
时创建AdminSite的子类admin_site = MyAdminSite()
您应该使用自定义name
参数(而非“管理员”):
admin_site = MyAdminSite(name='myadmin')