我有一个wagtail博客页面,我想显示一个子页面列表,包括日期,标题和简介。当前仅显示孩子的标题。
包含page.date和page.intro的
标记在呈现时为空。
这是博客页面的模型:
class BlogPost(Page):
date = models.DateField("Post date")
intro = models.CharField(max_length=250)
body = RichTextField(blank=True)
search_fields = Page.search_fields + [
index.SearchField('intro'),
index.SearchField('body'),
]
promote_panels = Page.promote_panels + [
FieldPanel('intro'),
]
content_panels = Page.content_panels + [
FieldPanel('date'),
FieldPanel('intro'),
FieldPanel('body', classname="full"),
]
class Meta:
# order on primary key to make sure it's unique
ordering = ('title', 'pk')
blog_index_page.html
{% extends "base.html" %}
{% load static wagtailcore_tags menu_tags %}
{% block content %}
<h1>{{ page.title }}</h1>
<div class="intro">{{ page.intro|richtext }}</div>
<div class="list-of-previews">
{% for page in self.get_children %}
<div class="blog-post-preview">
<p>{{ page.date }}</p>
<a href="{{ page.url }}">{{ page.title }}</a>
<p>{{ page.intro }}</p>
</div>
{% endfor %}
</div>
{% endblock %}
博客索引模型
class BlogIndexPage(Page):
intro = RichTextField(blank=True)
content_panels = Page.content_panels + [
FieldPanel('intro', classname="full"),
]
我希望能够显示page.date和page.intro