Html Django Wagtail在另一个模板页面中显示来自父级的子级
我有一个像这样的模型Html Django Wagtail在另一个模板页面中显示来自父级的子级,html,django,wagtail,Html,Django,Wagtail,我有一个像这样的模型 class StoryLinePage(ContentPage): body = StreamField([ ('related_reports', blocks.PageChooserBlock( 'content.ReportPage', icon='form', template='content/blocks/report_block.html') )
class StoryLinePage(ContentPage):
body = StreamField([
('related_reports', blocks.PageChooserBlock(
'content.ReportPage',
icon='form',
template='content/blocks/report_block.html')
),
], blank=True)
在这个模型中,我可以用HTML呈现相关的报告,我想呈现相关的报告
,但是从报告页面
模型
class ReportPage(ContentPage):
body = StreamField([
('heading', blocks.CharBlock(classname="full title")),
('paragraph', blocks.RichTextBlock()),
('image', ImageChooserBlock()),
('dashboard', blocks.PageChooserBlock(
'content.DashboardPage',
icon='code',
template='content/blocks/dashboard_block.html')
),
('table', TableBlock()),
], blank=True)
search_fields = ContentPage.search_fields + [
index.SearchField('body'),
]
content_panels = ContentPage.content_panels + [
StreamFieldPanel('body', classname="full"),
HelpPanel("", classname="edit-spacer"),
]
在report\u page.html中
我可以通过django模板标签访问StoryLinePage
{% if page.related_storyline.all%}
{% for story in page.related_storyline.all %}
<div id='storylines'>
<h4 class='storyline-header'>{{story.page.specific.title}}</h4>
</div>
{% endfor %}
{% endif %}
目前,所有呈现的都是故事情节.page.title
,如有任何帮助,将不胜感激
谢谢
{% if page.related_storyline.all%}
{% for story in page.related_storyline.all %}
<div id='storylines'>
<h4 class='storyline-header'>{{story.page.specific.title}}</h4>
<div class="header-bar"></div>
{% if page.related_storyline.related_reports.all%}
{% for report in page.related_storyline.related_reports %}
<a href={% pageurl story.page %} class="report-block-container">
<div class="report-block-text">
<p> {{report.page.specific.title}}</p>
</div>
</a>
{% endfor %}
{% endif %}
</div>
{% endfor %}
{% endif %}
</div>