I have the following StructBlock
and Page
model:
class PostGrid(blocks.StructBlock):
title = blocks.CharBlock()
post_1 = blocks.PageChooserBlock()
post_2 = blocks.PageChooserBlock()
class Meta:
template = 'post-grid.html'
class BlogIndex(Page):
body = StreamField([('POSTS', PostGrid()),])
class Meta:
template = 'base.html'
class PostPage(Page):
hero_title = models.CharField(max_length=255)
I want to render the attributes of post_1
and post_2
in the body
StreamField:
base.html
:
{% for block in page.body %}
{% include_block block %}
{% endfor %}
post-grid.html
:
{{ value.post_1.url }}
{{ value.post_1.hero_title }}
value.post_1.url
renders the URL fine. However, value.post_1.hero_title
is blank.
How do I render the Page attributes?