Read child pages from DB
This commit is contained in:
parent
19c4944f79
commit
720557d2a6
4 changed files with 17 additions and 3 deletions
|
@ -6,6 +6,10 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.image {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.media img {
|
.media img {
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.http.request import HttpRequest
|
||||||
from django.utils.functional import classproperty
|
from django.utils.functional import classproperty
|
||||||
from wagtail.admin.panels import FieldPanel
|
from wagtail.admin.panels import FieldPanel
|
||||||
from wagtail.images import get_image_model_string
|
from wagtail.images import get_image_model_string
|
||||||
|
@ -42,3 +43,10 @@ class ContentPage(BasePage, BaseContentMixin): # type: ignore[misc]
|
||||||
|
|
||||||
class ListingPage(BasePage, BaseContentMixin): # type: ignore[misc]
|
class ListingPage(BasePage, BaseContentMixin): # type: ignore[misc]
|
||||||
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
|
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
|
||||||
|
|
||||||
|
def get_context(self, request: HttpRequest) -> dict:
|
||||||
|
context = super().get_context(request)
|
||||||
|
context["child_pages"] = (
|
||||||
|
self.get_children().live().specific().select_related("hero_image")
|
||||||
|
)
|
||||||
|
return context
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
|
{% load wagtailcore_tags wagtailimages_tags %}
|
||||||
|
|
||||||
<article class="media listing-item">
|
<article class="media listing-item">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<figure class="media-left column is-3 image-column">
|
<figure class="media-left column is-3 image-column">
|
||||||
<p class="image">
|
<p class="image">
|
||||||
<img src="https://placekitten.com/g/600/300">
|
<img src="{% image_url page.hero_image 'width-300' %}">
|
||||||
</p>
|
</p>
|
||||||
</figure>
|
</figure>
|
||||||
<div class="media-content column">
|
<div class="media-content column">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="title is-3"><a href="#">Title</a></h2>
|
<h2 class="title is-3"><a href="{% pageurl page %}">{{ page.title }}</a></h2>
|
||||||
<h3 class="subtitle is-6">2022-04-15 4 minutes <a>#programming</a> <a href="#security">#security</a> <a>#website</a></h3>
|
<h3 class="subtitle is-6">2022-04-15 4 minutes <a>#programming</a> <a href="#security">#security</a> <a>#website</a></h3>
|
||||||
{% lorem 1 p %}
|
{% lorem 1 p %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
{% include "common/hero.html" %}
|
{% include "common/hero.html" %}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{% for i in 9|range %}
|
{% for page in child_pages %}
|
||||||
{% include "common/listing-item.html" %}
|
{% include "common/listing-item.html" %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue