And*_*ida 2 python django wagtail
我正在尝试将我自己的 css 插入到 wagtail 管理页面中。
\n\n\xd0\xa1onsidering 答案https://groups.google.com/forum/#!topic/wagtail/DYeTygB_F-8我使用 hook insert_editor_css。我在我的应用程序文件夹中创建wagtail_hooks.py并添加了以下代码:
from django.utils.html import format_html\nfrom django.contrib.staticfiles.templatetags.staticfiles import static\n\nfrom wagtail.wagtailcore import hooks\n\n\n@hooks.register(\'insert_editor_css\')\ndef editor_css():\n return format_html(\'<link rel="stylesheet" href="{}">\', static(\'css/admin.css\'))\nRun Code Online (Sandbox Code Playgroud)\n\n对于文档,它应该被执行,但没有插入 css 文件,甚至没有尝试执行它(错误或异常)。我猜(也许我错了)wagtail_hooks.py没有被处理。
有人能给我一些建议吗?提前致谢。
\n你需要:
INSTALLED_APPS设置中。wagtail_hooks.py. 您可以将其放在print模块级别的某个位置,或者在钩子函数定义中添加断点。确保使用正确的钩子:
insert_editor_css并用于仅向页面编辑器界面insert_editor_js添加额外的 css 或 js 。因此,您应该出现在页面创建或编辑屏幕上。css/admin.css
如果您想向所有管理页面添加额外的 css 或 js,您需要使用insert_global_admin_css或insert_global_admin_js.