【发布时间】:2019-01-07 18:02:46
【问题描述】:
我正在尝试将 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 的全部原因是它内置了一个可以自定义的功能,并且它支持图像。
-
我想与所见即所得一起使用的模型是 TextField()。所见即所得是应该自动应用还是我应该额外配置一些东西?