I have a CMS based on wagtail, and have recently re-written it in a more sensible fashion. I have written a script to migrate the old content to this new version, which is based on wagtail 2.3 (old version was on wagtail 1.11). I have written the migration script (to re-construct various foreign keys etc) and all content has been populated and seems to be working except for the render of StreamFields.
Frustratingly, when I switch back to my test db for v2, this works fine (content is rendered) - I've been scouring my databases for differences between the two rows (in wagtailcore_page or blog_blogpostpage) and can't see any difference. There's obviously something I'm missing in the way wagtail fetches StreamField content, can anyone enlighten me as to what I might have missed in the migration? Many thanks!!
models.py
class BlogPostPage(Page): # Individual blog post
template = 'blog/post_page.html'
parent_page_types = ['blog.BlogIndexPage']
show_in_menus_default = True
author = models.ForeignKey(
User, on_delete=models.PROTECT, default=1,
)
description = models.CharField(
max_length=300, blank=False,
help_text="Add a brief (max 300 characters) description for this blog post."
)
date = models.DateField(
"Post date",
help_text="This date may be displayed on the blog post. "
"It is not used to schedule posts to go live at a later date."
)
body = StreamField([
('heading', blocks.CharBlock(classname="full title")),
('paragraph', blocks.RichTextBlock()),
('embed', EmbedBlock()),
('image', ImageChooserBlock(classname='img-responsive')),
('code', CodeBlock(label='Code')),
('table', TableBlock(label='Table'))
], help_text="Create content by adding new blocks.")
table blog_blogpostpage entry:
"page_ptr_id","description","date","body","author_id"
23,"Now including Blog!","2018-12-06","[{""type"": ""paragraph"", ""value"": ""<p>Since the first release we've made some improvements and upgrades...</p>"", ""id"": ""25fe32be-2090-42dd-8e3e-4df53c494227""}]",15
migration_script.sh
INSERT INTO "public"."wagtailcore_page"("path","depth","numchild","title","slug","live","has_unpublished_changes","url_path","seo_title","show_in_menus","search_description","go_live_at","expire_at","expired","content_type_id","owner_id","locked","latest_revision_created_at","first_published_at","live_revision_id","last_published_at","draft_title")
VALUES
(E'00010002000O0001',4,0,E'Release: version 2',E'release-version-2',TRUE,FALSE,E'/home/blog/release-version-2/',E'',TRUE,E'',NULL,NULL,FALSE,6,15,FALSE,E'2018-12-06 16:58:10.897348+08',E'2018-12-06 16:58:10.926032+08',NULL,E'2018-12-06 16:58:10.926032+08',E'Release: version 2');
INSERT INTO "public"."blog_blogpostpage"("page_ptr_id","description","date","body","author_id")
VALUES
((SELECT id FROM wagtailcore_page WHERE path='00010002000O0001'),E'Now including Blog!',E'2018-12-06',E'[{"type": "paragraph", "value": "<p>Since the first release we've made some improvements and upgrades...</p>", "id": "25fe32be-2090-42dd-8e3e-4df53c494227"}]',15);
template.html
{% include_block page.body %}
^^^ Nothing is shown for the page.body field, but description, date and author are rendered.
Since the first release we've made some improvements and upgrades...
"", ""id"": ""25fe32be-2090-42dd-8e3e-4df53c494227""}] – Liz Dec 07 '18 at 06:12