Created
September 10, 2019 13:22
-
-
Save mwesterhof/85aaaaa4978f5187f567ad946ae36487 to your computer and use it in GitHub Desktop.
nested blocks, to reproduce validation issue for wagtail_react_streamfield
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# home/blocks.py | |
from wagtail.core import blocks | |
from wagtail.images.blocks import ImageChooserBlock | |
class SomeImageBlock(blocks.StructBlock): | |
title = blocks.CharBlock() | |
image = ImageChooserBlock() | |
class Meta: | |
template = 'home/blocks/some_image_block.html' | |
class SomeParagraphBlock(blocks.StructBlock): | |
title = blocks.CharBlock() | |
text = blocks.CharBlock() | |
class Meta: | |
template = 'home/blocks/some_paragraph_block.html' | |
class SomeContainerBlock(blocks.StructBlock): | |
title = blocks.CharBlock() | |
content = blocks.StreamBlock([ | |
('image', SomeImageBlock()), | |
('paragraph', SomeParagraphBlock()), | |
]) | |
class Meta: | |
template = 'home/blocks/some_container_block.html' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment