I'm trying to create a block that allows me to add multiple blocks, where each is a different size in a size estimator.
class SizeItem(blocks.StructBlock):
name = blocks.CharBlock(required=True)
image = ImageChooserBlock(required=True)
description = blocks.TextBlock(required=True)
class Meta: #noqa
icon = 'arrows-up-down'
label = 'Size Estimator Item'
class SizeEstimator(blocks.StructBlock):
description = blocks.TextBlock(required=False)
size_items = blocks.StreamBlock([
('size_item', SizeItem())
], required=False)
class Meta: #noqa
template = 'streams/size_estimator.html'
icon = 'list-ul'
label = 'Size Estimator'
The issue is that I need the names, images, and descriptions all grouped within different areas of the SizeEstimator template:
<div>
<div>
<ul>
<li>names</li>
</ul>
</div>
<div>
<div>
images
</div>
</div>
<div>
descritions
</div>
</div>
so I can't use a template on the SizeItem because there is no way to separate the pieces in the SizeEstimator template. But if I try:
<div class="se-wrap flexy">
<div class="se-sizes">
{% for item in self.size_items %}
<div class="se-size-btn">
{{item}}
</div>
{% endfor %}
</div>
</div>
I get plain text back with each SizeItem attribute name and value. I can't just pull the values like item.name because the output is blank.
What is a good way to add orderable blocks to another block where you can piece out the contents of the oderable blocks?