How to migrate from StaticBlock to StructBlock?
I have to change an already existing StaticBlock
to a StructBlock
:
class SomeBlock(blocks.StaticBlock):
pass
class Meta:
...
to:
class SomeBlock(blocks.StructBlock):
...
class Meta:
...
However if the wagtail page has already SomeBlock
configured in it, I receive the error:
NoneType is not iterable
Since I don't have anything inside the StaticBlock
. I need to write a custom data migration for this.
Based on Schema Operations listed, I couldn't find a way to change the actual block type. How do I approach this?
StructBlocks and StaticBlocks live inside StreamFields so you need a Wagtail-specific method for converting blocks within a StreamField. Please see https://wagtail.org/blog/google-summer-of-code-toolkit-for-streamfield-data-migrations-in-wagtail/ for a discussion of the issue. Then you can use the project described https://github.com/wagtail/wagtail-streamfield-migration-toolkit Or, if you want to try out Wagtail 4.2rc1, you can try the built in migration helpers: https://docs.wagtail.org/en/latest/advanced_topics/streamfield_migrations.html#streamfield-data-migrations