我正在尝试将Wagtail CMS集成到我现有的Django项目中。除了这个基本的安装之外,我还创建了一个名为wagtail_hooks.py的文件。到目前为止一切都很好,但我需要使用WYSIWYG编辑器上的Wagtail CMS。是否有一种方法可以访问Wagtail的models.py,以便在模型级别上使用第三方WYSIWYG编辑器?
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)发布于 2019-01-07 23:09:46
WYSIWYG编辑器,Draftail,基于DraftJS提供了一个优秀的WYSIWYG编辑器。它是高度可扩展的:
draftail.html
要使用它,可以将模型更改为使用wagtail.core.fields.RichTextField而不是TextField。
还有其他几个WYSIWYG编辑器可用,例如,您仍然可以在此设置中使用旧编辑器:
WAGTAILADMIN_RICH_TEXT_EDITORS = {
'default': {
'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea'
}
}祝好运!
https://stackoverflow.com/questions/54079489
复制相似问题