I'm trying to construct the carousel model
:
class Carousel(blocks.StructBlock):
heading = blocks.CharBlock(required=False)
carousel = blocks.ListBlock(
blocks.StructBlock([
('slide', blocks.StreamBlock([
('image', ImageChooserBlock()),
('video', EmbedBlock())]),
),
('description', blocks.RichTextBlock()),
])
)
Every slide consists of one image or video and a description.
I'm using StreamBlock
in here because I couldn't find any other more suitable structural block type which would allow to the user to choose between image and video. Ideally I need something similar to the ChoiceBlock
, except that the choices
argument should expect other block types.
Is that feasible? Or at least is there a way to limit how many sub-blocks
might be inserted from within the StreamBlock
?