Reputation: 1464
I'm trying to insert my own css into a wagtail admin page.
Сonsidering the answer https://groups.google.com/forum/#!topic/wagtail/DYeTygB_F-8 I use hook insert_editor_css
. I've created wagtail_hooks.py
in my app folder and added code below:
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'))
Towards to docs it should be executed but no css file inserted or even attempt to do it(errors or exceptions). I guess(maybe i'm wrong) wagtail_hooks.py
is not being processed.
Could anybody throw me some tips? Thanks in advance.
Upvotes: 2
Views: 2876
Reputation: 696
You need to:
INSTALLED_APPS
setting.wagtail_hooks.py
. You can just put print
somewhere on the module level or add a break point to hook function definition.Ensure that you use proper hook:
insert_editor_css
and insert_editor_js
used to add extra css or js only to the page editor interface. So your css/admin.css
should appear on a page create or edit screen.
If you want to add extra css or js to all admin pages you need to use insert_global_admin_css
or insert_global_admin_js
.
Upvotes: 5