I've got a wagtail page model with an existing streamfield. The streamfield has now changed format and I'd like the text content to migrated down a level into a streamblock.
The initial model (simplified):
class ProjectPage(Page):
description = StreamField(
[
("text", blocks.RichTextBlock()),
("image", ImageBlock()),
]
)
The new model (also simplified):
class ProjectPage(Page):
description = StreamField(
[
(
"section",
blocks.StreamBlock(
[
("text", blocks.RichTextBlock()),
("image", ImageBlock()),
]
),
)
],
)
Currently, the image blocks are empty, so only the text item needs migrating.
I tried looping through pages and doing old_data = page.description.raw_data then using that to make the new content [{'type': 'section', 'value': old_data}].
If I page.save() and get the value for page.description.raw_data, I see the new content, but the admin still shows the old values.
I'm guessing this is linked to revisions vs published versions but I can't figure out how to fix this.
Any pointers would be welcome!