0

我想为我的项目使用两个管理站点。每个都有 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'}”的仪表板

完整的错误跟踪: http: //pastebin.com/w8W2eRPd

问题出在哪里?

4

1 回答 1

1

好的,我已经发现了。在创建实例时创建 AdminSite 的子类

admin_site = MyAdminSite()

您应该使用自定义name参数(不是“管理员”):

admin_site = MyAdminSite(name='myadmin')
于 2013-02-26T20:06:10.873 回答