如何在 Wagtail CMS 中使用 WYSIWYG 编辑器?
How can I use WYSIWYG editor in Wagtail CMS?
我正在尝试将 Wagtail CMS 与我现有的 Django 项目集成。除了 this basic installation,我创建了一个名为 wagtail_hooks.py
的文件。到目前为止一切都很好,但我需要在 Wagtail CMS 上使用 WYSIWYG 编辑器。有没有办法为 Wagtail 访问 models.py,以便我可以在模型级别使用第三方所见即所得编辑器?
MY_APP/wagtail_hooks.py
from wagtail.contrib.modeladmin.options import (
ModelAdmin, modeladmin_register)
from .models import Store
class StoreAdmin(ModelAdmin):
model = Store
menu_label = 'Store' # ditch this to use verbose_name_plural from model
menu_icon = 'doc-full' # change as required
menu_order = 10 # will put in 3rd place (000 being 1st, 100 2nd)
add_to_settings_menu = False # or True to add your model to the Settings sub-menu
exclude_from_explorer = False # or True to exclude pages of this type from Wagtail's explorer view
list_display = ['id', 'status', 'typ', 'businessName',]
search_fields = ('businessName', 'created_by__username',)
# Now you just need to register your customised ModelAdmin class with Wagtail
modeladmin_register(StoreAdmin)
Wagtail 带有一个出色的所见即所得编辑器 Draftail,它基于 DraftJS。它是高度可扩展的:
http://docs.wagtail.io/en/v2.4/advanced_topics/customisation/extending_draftail.html
要使用它,您可以将模型更改为使用 wagtail.core.fields.RichTextField
而不是 TextField
。
还有其他几个所见即所得的编辑器可用,例如,您仍然可以使用具有此设置的旧编辑器:
WAGTAILADMIN_RICH_TEXT_EDITORS = {
'default': {
'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea'
}
}
祝你好运!
我正在尝试将 Wagtail CMS 与我现有的 Django 项目集成。除了 this basic installation,我创建了一个名为 wagtail_hooks.py
的文件。到目前为止一切都很好,但我需要在 Wagtail CMS 上使用 WYSIWYG 编辑器。有没有办法为 Wagtail 访问 models.py,以便我可以在模型级别使用第三方所见即所得编辑器?
MY_APP/wagtail_hooks.py
from wagtail.contrib.modeladmin.options import (
ModelAdmin, modeladmin_register)
from .models import Store
class StoreAdmin(ModelAdmin):
model = Store
menu_label = 'Store' # ditch this to use verbose_name_plural from model
menu_icon = 'doc-full' # change as required
menu_order = 10 # will put in 3rd place (000 being 1st, 100 2nd)
add_to_settings_menu = False # or True to add your model to the Settings sub-menu
exclude_from_explorer = False # or True to exclude pages of this type from Wagtail's explorer view
list_display = ['id', 'status', 'typ', 'businessName',]
search_fields = ('businessName', 'created_by__username',)
# Now you just need to register your customised ModelAdmin class with Wagtail
modeladmin_register(StoreAdmin)
Wagtail 带有一个出色的所见即所得编辑器 Draftail,它基于 DraftJS。它是高度可扩展的:
http://docs.wagtail.io/en/v2.4/advanced_topics/customisation/extending_draftail.html
要使用它,您可以将模型更改为使用 wagtail.core.fields.RichTextField
而不是 TextField
。
还有其他几个所见即所得的编辑器可用,例如,您仍然可以使用具有此设置的旧编辑器:
WAGTAILADMIN_RICH_TEXT_EDITORS = {
'default': {
'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea'
}
}
祝你好运!