I'm unable to get a list of blog pages to display on the index page. In my models.py I have a BlogPage and an IndexPage model, I have created a few blog pages, but when I access the Index page, they are not showing.
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Page, Orderable
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel, InlinePanel
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsearch import index
class IndexPage(Page):
intro = RichTextField(blank=True)
def child_pages(self):
return BlogPage.objects.live().child_of(self)
content_panels = Page.content_panels + [
FieldPanel('intro', classname='full'),
]
subpage_types = ['blog.BlogPage']
class BlogPage(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'),
)
content_panels = Page.content_panels + [
FieldPanel('date'),
FieldPanel('intro'),
FieldPanel('body', classname="full")
]
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% block body_class %}template-index_page{% endblock %}
{% block content %}
<div class="intro">{{ self.intro|richtext }}</div>
{% for page in self.child_pages %}
{{ page.title }}
{{ page.intro }}
{% endfor %}
{% endblock %}