blog2.0/blog/home/models.py

22 lines
660 B
Python

from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.admin.panels import FieldPanel, InlinePanel
from wagtail.fields import RichTextField
from wagtail.models import Orderable, Page
class HomePage(Page):
body = RichTextField(blank=True)
content_panels = Page.content_panels + [
FieldPanel("body"),
InlinePanel("links", heading="Links", label="Link"),
]
class HomePageLink(Orderable):
page = ParentalKey(HomePage, on_delete=models.CASCADE, related_name="links")
title = models.CharField(max_length=256)
link = models.URLField()
panels = [FieldPanel("title"), FieldPanel("link")]