好的,我找到了解决方案。以下是指导方针:
Mezzanine 允许用户自定义他们的仪表板提供功能并将其注册为包含标签。
文档: http: //mezzanine.jupo.org/docs/admin-customization.html -> 仪表板https://docs.djangoproject.com/en/1.7/howto/custom-template-tags/#inclusion-tags
要实现这样的功能,您需要执行以下步骤:
1) 在您的应用程序中添加一个templatetags 文件夹(不要忘记__init__.py文件)并在此包内创建一个名为“your_tags.py”的文件。
2) 在这个新文件中,添加一个函数来向您要在仪表板面板中添加的新仪表板提供数据。它可能看起来像这样:
from mezzanine import template
from your_app.models import Thing
register = template.Library()
@register.inclusion_tag('unpublished_things.html')
def show_unpublished_things():
plugins = Thing.objects.filter(published=False)
return {'things':things}
3)然后您需要创建包含标签中使用的“unpublished_things.html”文件,例如在您的应用程序的模板文件夹中创建这样一个文件。该文件可能如下所示(假设事物模型中有一个“get_admin_url”函数):
{% load i18n %}
<div class="group-collapsible">
<div class="module">
<table>
<caption>Unpublished things</caption>
{% for thing in things %}
<tr>
<th scope="row" width="100%"><a
href="{{ thing.get_admin_url }}">{{ thing.name }}</a></th>
<td> </td>
<td> </td>
</tr>
{% endfor %}
</table>
</div>
</div>
4) 要完成,您只需在local_settings.py(或 settings.py)中添加以下内容:
DASHBOARD_TAGS = (
("your_tags.show_unpublished_things", "mezzanine_tags.app_list"),
("comment_tags.recent_comments",),
("mezzanine_tags.recent_actions",),
)
此配置将自动添加由功能“show_unpublished_things”提供的生成的东西在第一行的顶部,在您的管理面板的仪表板中。
如果出现错误,请不要忘记重新启动服务器!