I have a wagtail blog page and I want display a list of child pages, including the dates, title and intro. Currently only the title of the children is being displayed.
The
tags that contain page.date and page.intro are empty when rendered.
Here is the model for blog page:
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 %}
Blog Index Model
class BlogIndexPage(Page):
intro = RichTextField(blank=True)
content_panels = Page.content_panels + [
FieldPanel('intro', classname="full"),
]
I would like to be able to display page.date and page.intro