我正在尝试测试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')
]
现在我正在尝试添加一个HomePage并在我的网站的管理部分添加一些html到body,但我不能这样做,因为我在chrome's
控制台中得到这个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)
wangtail版本是1.13.1
,任何想法?
StreamField
s需要使用StreamFieldPanel
,而不是FieldPanel
。
from wagtail.wagtailadmin.edit_handlers import StreamFieldPanel
# ...
content_panels = Page.content_panels + [
StreamFieldPanel('body')
]