blog2.0/blog/home/models.py

23 lines
660 B
Python
Raw Permalink Normal View History

2024-06-14 14:57:03 +02:00
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"),
2024-06-14 15:56:37 +02:00
InlinePanel("links", heading="Links", label="Link"),
2024-06-14 14:57:03 +02:00
]
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")]