Python 如何正确使用Wagtail管理中的钩子?
我正在尝试将自己的css插入wagtail管理页面 С考虑到答案,我使用hookPython 如何正确使用Wagtail管理中的钩子?,python,django,wagtail,Python,Django,Wagtail,我正在尝试将自己的css插入wagtail管理页面 С考虑到答案,我使用hookinsert\u editor\u css。我在我的应用程序文件夹中创建了wagtail\u hooks.py,并在下面添加了代码: from django.utils.html import format_html from django.contrib.staticfiles.templatetags.staticfiles import static from wagtail.wagtailcore impo
insert\u editor\u css
。我在我的应用程序文件夹中创建了wagtail\u hooks.py
,并在下面添加了代码:
from django.utils.html import format_html
from django.contrib.staticfiles.templatetags.staticfiles import static
from wagtail.wagtailcore import hooks
@hooks.register('insert_editor_css')
def editor_css():
return format_html('<link rel="stylesheet" href="{}">', static('css/admin.css'))
来自django.utils.html导入格式\u html
从django.contrib.staticfiles.templatetags.staticfiles导入静态
来自wagtail.wagtailcore导入挂钩
@hooks.register('insert\u editor\u css'))
def editor_css():
返回格式为html(“”,static('css/admin.css'))
对于文档,它应该被执行,但没有插入css文件,甚至没有尝试这样做(错误或异常)。我猜(也许我错了)wagtail\u hooks.py
没有被处理
谁能给我一些小费吗?提前感谢。您需要:
wagtail\u hooks.py
。您可以将print
放在模块级的某个位置,或者在钩子函数定义中添加断点css/admin.css
应该出现在页面创建或编辑屏幕上
如果你想添加额外的css或js到所有管理页面,你需要使用或谢谢你的回答。我尚未将我的应用程序添加到已安装的应用程序中