我只是在使用django框架来使用python。现在我想要我的管理仪表板与喷气仪表板更好的用户界面。我已经完成了与jet documentation link文档中完全相同的所有操作。在我的setting.py
JET_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard'
JET_APP_INDEX_DASHBOARD = 'dashboard.CustomAppIndexDashboard'
在我的dashboard.py中
class CustomIndexDashboard(Dashboard):
columns = 3
def init_with_context(self, context):
self.available_children.append(modules.LinkList)
self.available_children.append(modules.Feed)
self.available_children.append(google_analytics.GoogleAnalyticsVisitorsTotals)
self.available_children.append(google_analytics.GoogleAnalyticsVisitorsChart)
self.available_children.append(google_analytics.GoogleAnalyticsPeriodVisitors)
site_name = get_admin_site_name(context)
# append a link list module for "quick links"
self.children.append(modules.LinkList(
_('Quick links'),
layout='inline',
draggable=False,
deletable=False,
collapsible=False,
children=[
[_('Return to site'), '/'],
[_('Change password'),
reverse('%s:password_change' % site_name)],
[_('Log out'), reverse('%s:logout' % site_name)],
],
column=0,
order=0
))
# append an app list module for "Applications"
self.children.append(modules.AppList(
_('Applications'),
exclude=('auth.*',),
column=1,
order=0
))
# append an app list module for "Administration"
self.children.append(modules.AppList(
_('Administration'),
models=('auth.*',),
column=2,
order=0
))
# append a recent actions module
self.children.append(modules.RecentActions(
_('Recent Actions'),
10,
column=0,
order=1
))
# append a feed module
self.children.append(modules.Feed(
_('Latest Django News'),
feed_url='http://www.djangoproject.com/rss/weblog/',
limit=5,
column=1,
order=1
))
# append another link list module for "support".
self.children.append(modules.LinkList(
_('Support'),
children=[
{
'title': _('Django documentation'),
'url': 'http://docs.djangoproject.com/',
'external': True,
},
{
'title': _('Django "django-users" mailing list'),
'url': 'http://groups.google.com/group/django-users',
'external': True,
},
{
'title': _('Django irc channel'),
'url': 'irc://irc.freenode.net/django',
'external': True,
},
],
column=2,
order=1
))
class CustomAppIndexDashboard(AppIndexDashboard):
def init_with_context(self, context):
self.available_children.append(modules.LinkList)
self.children.append(modules.ModelList(
title=_('Application models'),
models=self.models(),
column=0,
order=0
))
self.children.append(modules.RecentActions(
include_list=self.get_app_content_types(),
column=1,
order=0
))
我得到了这个错误,我检查了所有可能的解决方案,但其中任何一个都是worked.Please帮助
return dashboard_cls(context, app_label=app_label)
TypeError: 'NoneType' object is not callable
发布于 2018-02-13 00:00:14
您的JET_INDEX_DASHBOARD和JET_APP_INDEX_DASHBOARD应该指向dashboard.py文件所在的位置。因此,例如,如果您的项目名称是MyProject,并且您在如下所示的位置放置了dashboard.py:
MyProject
|-SomeApp1
|
|-SomeApp2
|
|-MyProject
|--settings.py
|--wsgi.py
|--dashboard.py
|
|-manage.py
然后你的JET_INDEX_DASHBOARD = 'MyProject.dashboard.CustomIndexDashboard‘
要使用您的值,dashboard.py应该位于项目根文件夹中。
Django JET没有包含对该约定的确切解释,但这就是它在所有Python框架中的工作方式(例如。Scrapy)
发布于 2019-08-30 23:42:56
我得到了同样的错误。原来我的CustomIndexDashboard
有一个ImportError
。
希望这能有所帮助。
https://stackoverflow.com/questions/48556340
复制相似问题