gpt4 book ai didi

python - wagtail rawhtmlblock 错误?

转载 作者:行者123 更新时间:2023-12-03 20:18:43 25 4
gpt4 key购买 nike

我正在尝试测试 wagtail RawHTMLBlock,这是我的代码 (models.py):

from __future__ import absolute_import, unicode_literals
from wagtail.wagtailcore import blocks
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore.models import Page
from wagtail.wagtailadmin.edit_handlers import FieldPanel


class HomePage(Page):
body = StreamField([
('raw_html', blocks.RawHTMLBlock()),
])

content_panels = Page.content_panels + [
FieldPanel('body')
]

现在我正在尝试添加一个主页并在我网站的管理部分向正文添加一些 html,但我做不到,因为我在 chrome 的 中遇到了这个 js 错误控制台:

stream.js:87 Uncaught TypeError: Cannot read property 'initializer' of undefined
at Object.onInitializeMember (stream.js:87)
at postInsertMember (sequence.js:95)
at Object.self.insertMemberAtStart (sequence.js:196)
at Object.onChooseBlock (stream.js:140)
at HTMLButtonElement.<anonymous> (stream.js:60)
at HTMLButtonElement.dispatch (jquery-2.2.1.min.js:3)
at HTMLButtonElement.r.handle (jquery-2.2.1.min.js:3)

wagtail 版本是 1.13.1,有什么想法吗?

最佳答案

StreamField需要使用StreamFieldPanel,而不是FieldPanel

from wagtail.wagtailadmin.edit_handlers import StreamFieldPanel

# ...
content_panels = Page.content_panels + [
StreamFieldPanel('body')
]

关于python - wagtail rawhtmlblock 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47955851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com