|
|
|
@ -5,6 +5,7 @@ from wagtail.core.fields import RichTextField
|
|
|
|
|
from wagtail.admin.edit_handlers import FieldPanel
|
|
|
|
|
from wagtail.search import index
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BlogIndexPage(Page):
|
|
|
|
|
intro = RichTextField(blank=True)
|
|
|
|
|
|
|
|
|
@ -12,6 +13,16 @@ class BlogIndexPage(Page):
|
|
|
|
|
FieldPanel('intro', classname="full")
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
def get_context(self, request, *args, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Overrides the default context to include only published pages, ordered by reverse chronological order.
|
|
|
|
|
These child pages can be accessed in the template using `blogpages` instead of page.get_children.
|
|
|
|
|
"""
|
|
|
|
|
context = super().get_context(request)
|
|
|
|
|
blogpages = self.get_children().live().order_by("-first_published_at")
|
|
|
|
|
context["blogpages"] = blogpages
|
|
|
|
|
return context
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BlogPage(Page):
|
|
|
|
|
date = models.DateField("Post date")
|
|
|
|
|