1
Fork 0

Add blog pages to index

This commit is contained in:
Jake Howard 2016-12-29 15:47:09 +00:00
parent 086ab7e245
commit 9769cc58c4
2 changed files with 15 additions and 1 deletions

View file

@ -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

View file

@ -96,6 +96,15 @@
<hr class="light">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
{% for post in blog_posts %}
<div class="row">
<div class="col-xs-12">
<p class="h3"><a href="{{ post.url }}">{{ post.title }}</a></p>
<p>{{ post.get_meta_description }}</p>
</div>
</div>
<hr class="light" />
{% endfor %}
</div>
</div>
<a href="/blog/" class="btn btn-primary-dark btn-xl">View all posts</a>