我只是使用django框架进入python。现在我希望我的管理仪表板上有更好的ui和喷气式仪表板。我完成了与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
))
我得到了这个错误,我经历了所有可能的解决方案,但其中任何一个都有效。请帮助
return dashboard_cls(context, app_label=app_label)
TypeError: 'NoneType' object is not callable
答案 0 :(得分:0)
您的 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)
答案 1 :(得分:0)
我遇到了同样的错误。原来我的std::apply([](auto&... cols){ (f(cols), ...); }, m_Columns);
auto columns = std::apply([](auto&... cols){
return std::array<IColumn*, sizeof...(cols)>{{cols...}};
},
m_Columns);
有一个cell: row => (
<div>
{row.addresses.map(({ addressType, id }) => (
<div key={id}>{addressType}</div>
))}
</div>
),
。
希望这会有所帮助。