I try to render a StreamField of a child page in a Page. I don't manage to render the different StructField within the StreamField. Here is my code
class DefinitionPage(Page):
body = StreamField([
('definition', blocks.StructBlock([
('heading', blocks.CharBlock(label='Titre')),
('paragraph', blocks.RichTextBlock(label='Paragraphe')),
]))
])
content_panels = Page.content_panels + [
StreamFieldPanel('body'),
]
my template. (DefinitionPage is a child of this page.)
{% for post in page.get_children %}
<h2><a href="{% pageurl post %}">{{ post.title }}</a></h2>
{% for block in post.body %}
{% include_block block %}
{% endfor %}
{% endfor %}
post.title is ok but it's like there is no block in post.body. I tried so many things and {% include_block block %} is certainly wrong. I also tried to add a custom template for the StructBlock without success.
How can I do ? I am using Django 2.0 and wagtail 2.0 (I'm new to wagtail but I read the doc) Best regards