From 9769cc58c4c3221124a07695ad41b7c79fd32c73 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 29 Dec 2016 15:47:09 +0000 Subject: [PATCH] Add blog pages to index --- project/home/models.py | 7 ++++++- templates/home/home_page.html | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/project/home/models.py b/project/home/models.py index b4ad419..709ea4d 100755 --- a/project/home/models.py +++ b/project/home/models.py @@ -1,7 +1,7 @@ from wagtail.wagtailcore.models import Page from wagtail.wagtailcore.fields import RichTextField from wagtail.wagtailadmin.edit_handlers import FieldPanel - +from project.blog.models import BlogPage from project.common.models import Entity @@ -13,3 +13,8 @@ class HomePage(Entity): content_panels = Page.content_panels + [ FieldPanel('body', classname="full") ] + + def get_context(self, *args, **kwargs): + context = super().get_context(*args, **kwargs) + context['blog_posts'] = BlogPage.objects.live().order_by('-post_date')[:4] + return context diff --git a/templates/home/home_page.html b/templates/home/home_page.html index bbabc57..3bf7122 100755 --- a/templates/home/home_page.html +++ b/templates/home/home_page.html @@ -96,6 +96,15 @@
+ {% for post in blog_posts %} +
+
+

{{ post.title }}

+

{{ post.get_meta_description }}

+
+
+
+ {% endfor %}
View all posts