首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Wagtail CMS中使用WYSIWYG编辑器?

如何在Wagtail CMS中使用WYSIWYG编辑器?
EN

Stack Overflow用户
提问于 2019-01-07 18:02:46
回答 1查看 1.6K关注 0票数 0

我正在尝试将Wagtail CMS集成到我现有的Django项目中。除了这个基本的安装之外,我还创建了一个名为wagtail_hooks.py的文件。到目前为止一切都很好,但我需要使用WYSIWYG编辑器上的Wagtail CMS。是否有一种方法可以访问Wagtail的models.py,以便在模型级别上使用第三方WYSIWYG编辑器?

MY_APP/wagtail_hooks.py

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-07 23:09:46

WYSIWYG编辑器,Draftail,基于DraftJS提供了一个优秀的WYSIWYG编辑器。它是高度可扩展的:

draftail.html

要使用它,可以将模型更改为使用wagtail.core.fields.RichTextField而不是TextField

还有其他几个WYSIWYG编辑器可用,例如,您仍然可以在此设置中使用旧编辑器:

代码语言:javascript
复制
WAGTAILADMIN_RICH_TEXT_EDITORS = {
    'default': {
        'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea'
    }
}

祝好运!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54079489

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档