[Answered ]-Carousel Model Definition or Block

2đź‘Ť

âś…

The main benefit of the StructBlock / StreamField approach is the ability to mix different block types in the sequence – so, for example, you could define ImageCarouselBlock and VideoCarouselBlock to have a carousel that mixes images and videos.

If you only have one kind of object in the sequence, there’s not much to choose between the two approaches. However, using a child model / InlinePanel is arguably nicer from a data modelling point of view, as it ensures that each object gets a real database entry (unlike StreamField where the data is stored in a single JSON field), meaning that you can run database queries against that data. (It’s a bit hard to find a non-contrived example of why you’d want to do this with a carousel – but you could say things like “give me all of the NewsPages that include image X in their carousel”.)

👤gasman

Leave a comment